﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.IO;
using HU8.Helpers.Files.Resource;
using System.Web.Script.Services;
using HU8.Helpers.Base;
using HU8.Helpers.Files;
using HU8.Web.FileExplorer.FileExplorer.Config;
using XMK.Tadong.Model;
using XMK.Tadong.Biz;
using System.Data;
using System.Configuration;
using HU8.Web.FileExplorer;
using XMK.Tadong.Model.Cond;


namespace HU8.Web.FileExplorer.FileExplorer.WebServices
{
    /// <summary>
    /// FileService 的摘要说明
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务，请取消对下行的注释。
    [System.Web.Script.Services.ScriptService]
    public class FileService : System.Web.Services.WebService
    {
        private FileExplorerConfig config;
        private LanguageDictionary dictionary;
        private LanguageDictionary lang_server;
        public FileService()
        {
            config = new FileExplorerConfig(Server, Context);
            //dictionary = new LanguageDictionary(config.Language, Server);//会有点问题
            //英文化
            string Languages = "1";
            if (Context.Request.Cookies["_language_"].Value == "0")
            {
                Languages = "en";
            }
            else
            {
                Languages = "zh";
            }
            lang_server = Application[Languages] as LanguageDictionary;

        }


        public string GetBasePath()
        {
            return config.FilesPath; //Server.MapPath(config.BasePath);
        }

        public string GetTempPath()
        {
            string p = config.TempPath;
            string serverPath = Server.MapPath(p);
            if (!Directory.Exists(serverPath))
            {
                Directory.CreateDirectory(serverPath);
            }
            return p;
        }

        public string GetThumbPath()
        {
            string p = config.ThumbConfig.ThumbPath;
            string serverPath = Server.MapPath(p);
            if (!Directory.Exists(serverPath))
            {
                Directory.CreateDirectory(serverPath);
            }
            return p;
        }




        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public JsonResponse GetParentId(string folderId)
        {
            JsonResponse response = new JsonResponse();
            response.success = true;
            try
            {

            }
            catch (Exception ex)
            {
                response.success = false;
                response.message = ex.Message;
            }

            return response;
        }




        /// <summary>
        /// 文件信息
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public FolderFile GetFileInfo(string path)
        {
            if (Session != null)
                config.SubPath = Session["sub_path"].ToString();

            path = path.Replace("~", config.FilesPath);
            string physicalPath = path;//Server.MapPath(path);
            FolderFile fi = new FolderFile(physicalPath, GetBasePath());
            return fi;
        }
        /// <summary>
        /// 文件夹信息
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public Folder GetFolderInfo(string path)
        {
            if (Session != null)
                config.SubPath = Session["sub_path"].ToString();

            path = path.Replace("~", config.FilesPath);
            string physicalPath = path;// Server.MapPath(path);
            Folder di = new Folder(physicalPath, GetBasePath(), config.Language);
            //di.Folders = FileHelper.GetFolderList(physicalPath, GetBasePath());
            //di.Files = FileHelper.GetFileList(physicalPath, GetBasePath());
            return di;
        }
        /// <summary>
        /// 文件夹信息  
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public Folder GetFolder(string path)
        {
            if (Session != null && Session["sub_path"] != null)
                config.SubPath = Session["sub_path"].ToString();
            // string testPath = "D:\\Masm\\";
            path = path.Replace("~/", config.FilesPath);
            //path = path.Replace("~/", testPath);
            //string physicalPath = Server.MapPath(path);
            string physicalPath = path;
            Folder di = new Folder(physicalPath, GetBasePath(), config.Language);
            try
            {
                List<Folder> folders = FileHelper.GetFolderList(physicalPath, GetBasePath());
                di.Folders = new List<Folder>();
                foreach (Folder f in folders)
                {
                    if (f.Name == "待审核")
                        continue;
                    if (Allowed(f.RelativePath, "r"))
                    {
                        di.Folders.Add(f);
                    }
                }

                List<FolderFile> files = FileHelper.GetFileList(physicalPath, GetBasePath());
                di.Files = new List<FolderFile>();
                foreach (FolderFile f in files)
                {
                    if (f.Extension.ToLower() == ".swf")
                    {
                        continue;
                    }
                    if (f.Extension.ToLower() == ".pdf")
                    {
                        if (f.Name.Contains("(转)"))
                        {
                            continue;
                        }
                    }
                    if (Allowed(f.RelativePath, "r"))
                    {
                        di.Files.Add(f);
                    }
                }
            }
            catch (Exception ex)
            {
                di.ErrorOccured = true;
                di.Error += ex.Message;
            }
            try
            {
                //制造一些缩略图
                ThumbnailHelper.GenerateThumbnailsInFolder(physicalPath, GetBasePath(), Server.MapPath(GetThumbPath()));
            }
            catch (Exception ex)
            {
                //缩略图错误不算错误。。。
                //di.ErrorOccured = true;
                di.Error += ex.Message;
            }
            return di;
        }

        /// <summary>
        /// 通过文件ID获取文件类型
        /// </summary>
        /// <param name="File_ID"></param>
        /// <returns></returns>
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public string getFile_Ext(string File_ID, string FileSpace_Type)
        {
            string File_Ext = "";
            if (FileSpace_Type.Equals("individual"))
            {
                TB_PERSON_FILEInfo model = new TB_PERSON_FILEInfo();
                TB_PERSON_FILEBiz bll = new TB_PERSON_FILEBiz();
                model = bll.GetFileInfoById(File_ID);
                EXTBiz biz = new EXTBiz();
                 ExtTypeinfo extcode = biz.getExtCodeByExtent(model.FILE_NAME.Substring(model.FILE_NAME.LastIndexOf('.') + 1));

                ///获取格式
                File_Ext = extcode.EXT_CODE;//文档格式
            }
            else if (FileSpace_Type.Equals("Team"))
            {
                TB_TEAM_FILEInfo model = new TB_TEAM_FILEInfo();
                TB_TEAM_FILEBiz bll = new TB_TEAM_FILEBiz();
                model = bll.GetTeamFile(File_ID);
                EXTBiz biz = new EXTBiz();
                ExtTypeinfo extcode = biz.getExtCodeByExtent(model.FILE_NAME.Substring(model.FILE_NAME.LastIndexOf('.') + 1));

                ///获取格式
                File_Ext = extcode.EXT_CODE;//文档格式
            }
            else if (FileSpace_Type.Equals("project"))
            {
                TB_XMK_FILEInfo model = new TB_XMK_FILEInfo();
                Tb_Xmk_FileBiz bll = new Tb_Xmk_FileBiz();
                model = bll.QueryById(File_ID);
                EXTBiz biz = new EXTBiz();
                ExtTypeinfo extcode = biz.getExtCodeByExtent(model.FILE_NAME.Substring(model.FILE_NAME.LastIndexOf('.') + 1));

                ///获取格式
                File_Ext = extcode.EXT_CODE;//文档格式
            }
            return File_Ext;
        }

        /// <summary>
        /// 文件夹信息  
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public string GetNavigate(string path, string FileType)
        {
            int id = 0;
            if (path == "~/")
            {
                id = 0;
            }
            else if (path == "null")
            {
                id = 0;
            }
            else
            {
                id = (int)Convert.ToSingle(path);
            }

            string Navigate = "";
            string SQL = "";
            if (FileType.Equals("PERSON"))
            {
                SQL = @"select * from TB_TREE_PERSON start with obj_id=" + id + " connect by prior p_obj_id = obj_id ";
            }
            else if (FileType.Equals("TEAM"))
            {
                SQL = @"select * from TB_TREE_TEAM start with obj_id=" + id + " connect by prior p_obj_id = obj_id ";
            }
            else if (FileType.Equals("XMK"))
            {
                SQL = @"select * from TB_TREE_XMK start with obj_id=" + id + " connect by prior p_obj_id = obj_id ";
            }
            YQCJDBLL bll = new YQCJDBLL();
            DataTable dt = bll.QueryData(SQL);
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                Navigate += dt.Rows[i]["OBJ_NAME"].ToString() + ":" + dt.Rows[i]["OBJ_ID"].ToString() + ";";
            }
            string newNavigate = "";
            if (!string.IsNullOrEmpty(Navigate))
            {
                Navigate = Navigate.Remove(Navigate.LastIndexOf(";"), 1);
                string[] Navigates = Navigate.Split(';');
                Array.Reverse(Navigates);
                for (int i = 0; i < Navigates.Length; i++)
                {
                    newNavigate += Navigates[i] + ":";
                }
                newNavigate = newNavigate.Remove(newNavigate.LastIndexOf(":"), 1);

            }
            return newNavigate;
        }

        /// <summary>
        /// 文件排序
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public Folder DataOrder(string op, string path, int pageNum, int size, string FileType, string ID)
        {
            int id = 0;
            if (path == "~/")
            {
                id = 0;
            }
            else
            {
                id = (int)Convert.ToSingle(path);
            }
            if (op == "mubiao")
            {
                op = "DEST_OBJ";
            }
            else if (op == "yewu")
            {
                op = "BIZ_OBJ";
            }
            else if (op == "date")
            {
                op = "CREATE_TIME";
            }
            else if (op == "daxiao")
            {
                op = "FILE_SIZE";
            }
            else if (op == "geshi")
            {
                op = "FILE_EXT";
            }

            string strId = id.ToString();
            int folderSize = 0;
            Folder di = new Folder();
            //个人
            if (FileType == "individual")
            {
                TB_PERSON_FILEBiz fileBiz = new TB_PERSON_FILEBiz();
                TB_Tree_ObjectBiz objBiz = new TB_Tree_ObjectBiz();
                List<TB_Tree_ObjectInfo> objInfos = objBiz.QueryChildObjectById(id, ID, "", "PERSON");  //FileHelper.GetFolderList(physicalPath, GetBasePath());
                List<Folder> folders = new List<Folder>();
                di.Folders = new List<Folder>();
                int startFolderIndex = (pageNum - 1) * size;
                int endFolderIndex = (pageNum) * size;
                if (endFolderIndex > objInfos.Count)
                {
                    endFolderIndex = objInfos.Count;
                }

                for (int i = startFolderIndex; i < endFolderIndex; i++)
                {
                    TB_Tree_ObjectInfo obj = objInfos[i];
                    Folder folder = new Folder();
                    folder.Exists = true;
                    folder.Name = obj.ObjectName;
                    folder.Attributes = "Directory";
                    folder.IsArchive = false;
                    folder.LastModified = Convert.ToDateTime(obj.CreateTime);
                    folder.LastAccessed = Convert.ToDateTime(obj.CreateTime);
                    // folder.
                    folder.Size = 0;
                    //存储父节点id，用于项目库返回操作
                    folder.Attributes = Convert.ToString(obj.PObjectID);
                    folder.Created = Convert.ToDateTime(obj.CreateTime);
                    folder.IsWritable = true;
                    folder.RelativePath = obj.ObjectID.ToString();
                    folder.FileCount = fileBiz.GetCountByDestObj(obj.ObjectID.ToString());
                    folder.FolderCount = objBiz.GetChildCountById1(obj.ObjectID, ID, "", "PERSON");
                    folder.Permission = "<table class='fe-permissions'><thead><tr><th>User</th><th>whether to allow </th><th>right</th></tr></thead><tbody><tr><td>BUILTIN\\Administrators</td><td>Allow</td><td>FullControl</td></tr><tr><td>BUILTIN\\Administrators</td><td>Allow</td><td>268435456</td></tr><tr><td>NT AUTHORITY\\SYSTEM</td><td>Allow</td><td>FullControl</td></tr><tr><td>NT AUTHORITY\\SYSTEM</td><td>Allow</td><td>268435456</td></tr><tr><td>NT AUTHORITY\\Authenticated Users</td><td>Allow</td><td>Modify, Synchronize</td></tr><tr><td>NT AUTHORITY\\Authenticated Users</td><td>Allow</td><td>-536805376</td></tr><tr><td>BUILTIN\\Users</td><td>Allow</td><td>ReadAndExecute, Synchronize</td></tr><tr><td>BUILTIN\\Users</td><td>Allow</td><td>-1610612736</td></tr></tbody></table>";
                    di.Folders.Add(folder);
                    di.FolderCount += 1;
                    folderSize++;
                }


                di.Files = new List<FolderFile>();

                int startNum = (pageNum - 1) * size;
                int endNum = pageNum * size - objInfos.Count;
                int total = 0;
                if (startNum != 0)
                {
                    startNum -= objInfos.Count;
                }
                DataTable dt_xmk_file = fileBiz.GetModelByDestObjAndType(strId, op, startNum, endNum + 1, ID, ref total);
                di.FileCount = total + objInfos.Count;

                foreach (DataRow dr in dt_xmk_file.Rows)
                {
                    FolderFile file = new FolderFile();
                    string fileName = dr["FILE_NAME"].ToString();
                    file.Name = fileName;
                    file.RelativePath = dr["FILE_ID"].ToString();
                    // di.FileCount += 1;
                    //file.Path = fileName;//dr["DEST_OBJ"].ToString();
                    if (!Convert.IsDBNull(dr["FILE_SIZE"]))
                    {
                        string strSize = Convert.ToString(dr["FILE_SIZE"]);
                        strSize = strSize.ToLower();
                        if (strSize.Contains('m'))
                        {
                            strSize = strSize.Replace("mb", "");
                            strSize = strSize.Replace('m', ' ');
                            file.Size = (int)(Convert.ToSingle(strSize.Trim()) * 1024 * 1024 + 1);
                        }
                        else if (strSize.Contains('k'))
                        {
                            strSize = strSize.Replace("kb", "");
                            strSize = strSize.Replace('k', ' ');
                            file.Size = (int)(Convert.ToSingle(strSize.Trim()) * 1024 + 1);
                        }
                        else
                        {
                            // file.Size = ;
                        }

                    }
                    file.LastModified = Convert.ToDateTime(dr["UPD_TIME"]);
                    file.Extension = fileName.Substring(fileName.LastIndexOf('.'));
                    di.Files.Add(file);
                }
            }
            //课题组
            else if (FileType == "group")
            {
                string userId = Context.Request.Cookies["user_id"].Value;
                TB_TEAM_FILEBiz fileBiz = new TB_TEAM_FILEBiz();
                TB_Tree_ObjectBiz objBiz = new TB_Tree_ObjectBiz();
                List<TB_Tree_ObjectInfo> objInfos = objBiz.QueryChildObjectById(id, userId, ID, "TEAM");  //FileHelper.GetFolderList(physicalPath, GetBasePath());
                List<Folder> folders = new List<Folder>();
                di.Folders = new List<Folder>();
                int startFolderIndex = (pageNum - 1) * size;
                int endFolderIndex = (pageNum) * size;
                if (endFolderIndex > objInfos.Count)
                {
                    endFolderIndex = objInfos.Count;
                }

                for (int i = startFolderIndex; i < endFolderIndex; i++)
                {
                    TB_Tree_ObjectInfo obj = objInfos[i];
                    Folder folder = new Folder();
                    folder.Exists = true;
                    folder.Name = obj.ObjectName;
                    folder.Attributes = "Directory";
                    folder.IsArchive = false;
                    folder.LastModified = Convert.ToDateTime(obj.CreateTime);
                    folder.LastAccessed = Convert.ToDateTime(obj.CreateTime);
                    // folder.
                    folder.Size = 0;
                    //存储父节点id，用于项目库返回操作
                    folder.Attributes = Convert.ToString(obj.PObjectID);
                    folder.Created = Convert.ToDateTime(obj.CreateTime);
                    folder.IsWritable = true;
                    folder.RelativePath = obj.ObjectID.ToString();
                    folder.FileCount = fileBiz.GetCountByDestObj(obj.ObjectID.ToString());
                    folder.FolderCount = objBiz.GetChildCountById1(obj.ObjectID, userId, ID, "TEAM");
                    folder.Permission = "<table class='fe-permissions'><thead><tr><th>Uesr</th><th>whether to allow</th><th>right</th></tr></thead><tbody><tr><td>BUILTIN\\Administrators</td><td>Allow</td><td>FullControl</td></tr><tr><td>BUILTIN\\Administrators</td><td>Allow</td><td>268435456</td></tr><tr><td>NT AUTHORITY\\SYSTEM</td><td>Allow</td><td>FullControl</td></tr><tr><td>NT AUTHORITY\\SYSTEM</td><td>Allow</td><td>268435456</td></tr><tr><td>NT AUTHORITY\\Authenticated Users</td><td>Allow</td><td>Modify, Synchronize</td></tr><tr><td>NT AUTHORITY\\Authenticated Users</td><td>Allow</td><td>-536805376</td></tr><tr><td>BUILTIN\\Users</td><td>Allow</td><td>ReadAndExecute, Synchronize</td></tr><tr><td>BUILTIN\\Users</td><td>Allow</td><td>-1610612736</td></tr></tbody></table>";
                    di.Folders.Add(folder);
                    di.FolderCount += 1;
                    folderSize++;
                }


                di.Files = new List<FolderFile>();

                int startNum = (pageNum - 1) * size;
                int endNum = pageNum * size - objInfos.Count;
                int total = 0;
                if (startNum != 0)
                {
                    startNum -= objInfos.Count;
                }
                DataTable dt_xmk_file = fileBiz.GetModelByDestObjAndType(op, strId, startNum, endNum + 1, ID, userId, ref total);
                di.FileCount = total + objInfos.Count;

                foreach (DataRow dr in dt_xmk_file.Rows)
                {
                    FolderFile file = new FolderFile();
                    string fileName = dr["FILE_NAME"].ToString();
                    file.Name = fileName;
                    file.RelativePath = dr["FILE_ID"].ToString();
                    if (!Convert.IsDBNull(dr["FILE_SIZE"]))
                    {
                        string strSize = Convert.ToString(dr["FILE_SIZE"]);
                        strSize = strSize.ToLower();
                        if (strSize.Contains('m'))
                        {
                            strSize = strSize.Replace("mb", "");
                            strSize = strSize.Replace('m', ' ');
                            file.Size = (int)(Convert.ToSingle(strSize.Trim()) * 1024 * 1024 + 1);
                        }
                        else if (strSize.Contains('k'))
                        {
                            strSize = strSize.Replace("kb", "");
                            strSize = strSize.Replace('k', ' ');
                            file.Size = (int)(Convert.ToSingle(strSize.Trim()) * 1024 + 1);
                        }
                        else
                        {
                            // file.Size = ;
                        }

                    }
                    file.LastModified = Convert.ToDateTime(dr["UPD_TIME"]);
                    file.Extension = fileName.Substring(fileName.LastIndexOf('.'));
                    di.Files.Add(file);
                }
            }
            //项目库
            else if (FileType == "project")
            {
                Tb_Xmk_FileBiz fileBiz = new Tb_Xmk_FileBiz();
                TB_Tree_ObjectBiz objBiz = new TB_Tree_ObjectBiz();
                List<TB_Tree_ObjectInfo> objInfos = objBiz.GetChildById(id, TreeType.XMK);  //FileHelper.GetFolderList(physicalPath, GetBasePath());
                List<Folder> folders = new List<Folder>();
                di.Folders = new List<Folder>();
                int startFolderIndex = (pageNum - 1) * size;
                int endFolderIndex = (pageNum) * size;
                if (endFolderIndex > objInfos.Count)
                {
                    endFolderIndex = objInfos.Count;
                }

                for (int i = startFolderIndex; i < endFolderIndex; i++)
                {
                    TB_Tree_ObjectInfo obj = objInfos[i];
                    Folder folder = new Folder();
                    folder.Exists = true;
                    folder.Name = obj.ObjectName;
                    folder.Attributes = "Directory";
                    folder.IsArchive = false;
                    folder.LastModified = Convert.ToDateTime(obj.CreateTime);
                    folder.LastAccessed = Convert.ToDateTime(obj.CreateTime);
                    // folder.
                    folder.Size = 0;
                    //存储父节点id，用于项目库返回操作
                    folder.Attributes = Convert.ToString(obj.PObjectID);
                    folder.Created = Convert.ToDateTime(obj.CreateTime);
                    folder.IsWritable = true;
                    folder.RelativePath = obj.ObjectID.ToString();
                    folder.FileCount = fileBiz.GetCountByDestObj(obj.ObjectID.ToString());
                    folder.FolderCount = objBiz.GetChildCountById(obj.ObjectID);
                    folder.Permission = "<table class='fe-permissions'><thead><tr><th>Uesr</th><th>whether to allow</th><th>right</th></tr></thead><tbody><tr><td>BUILTIN\\Administrators</td><td>Allow</td><td>FullControl</td></tr><tr><td>BUILTIN\\Administrators</td><td>Allow</td><td>268435456</td></tr><tr><td>NT AUTHORITY\\SYSTEM</td><td>Allow</td><td>FullControl</td></tr><tr><td>NT AUTHORITY\\SYSTEM</td><td>Allow</td><td>268435456</td></tr><tr><td>NT AUTHORITY\\Authenticated Users</td><td>Allow</td><td>Modify, Synchronize</td></tr><tr><td>NT AUTHORITY\\Authenticated Users</td><td>Allow</td><td>-536805376</td></tr><tr><td>BUILTIN\\Users</td><td>Allow</td><td>ReadAndExecute, Synchronize</td></tr><tr><td>BUILTIN\\Users</td><td>Allow</td><td>-1610612736</td></tr></tbody></table>";
                    di.Folders.Add(folder);
                    di.FolderCount += 1;
                    folderSize++;
                }
                di.Files = new List<FolderFile>();

                int startNum = (pageNum - 1) * size;
                int endNum = pageNum * size - objInfos.Count;
                int total = 0;
                if (startNum != 0)
                {
                    startNum -= objInfos.Count;
                }
                DataTable dt_xmk_file = fileBiz.GetModelByDestObjAndType(op, strId, startNum, endNum + 1, ref total);
                di.FileCount = total + objInfos.Count;

                foreach (DataRow dr in dt_xmk_file.Rows)
                {
                    FolderFile file = new FolderFile();
                    string fileName = dr["FILE_NAME"].ToString();
                    file.Name = fileName;
                    file.RelativePath = dr["FILE_ID"].ToString();
                    if (!Convert.IsDBNull(dr["FILE_SIZE"]))
                    {
                        string strSize = Convert.ToString(dr["FILE_SIZE"]);
                        strSize = strSize.ToLower();
                        if (strSize.Contains('m'))
                        {
                            strSize = strSize.Replace("mb", "");
                            strSize = strSize.Replace('m', ' ');
                            file.Size = (int)(Convert.ToSingle(strSize.Trim()) * 1024 * 1024 + 1);
                        }
                        else if (strSize.Contains('k'))
                        {
                            strSize = strSize.Replace("kb", "");
                            strSize = strSize.Replace('k', ' ');
                            file.Size = (int)(Convert.ToSingle(strSize.Trim()) * 1024 + 1);
                        }
                        else
                        {
                            // file.Size = ;
                        }

                    }
                    file.LastModified = Convert.ToDateTime(dr["UPD_TIME"]);
                    file.Extension = fileName.Substring(fileName.LastIndexOf('.'));
                    di.Files.Add(file);
                }
            }
            return di;
        }


        /// <summary>
        /// 非结构化搜索
        /// </summary>
        /// <param name="path">文件夹ID</param>
        /// <param name="keyword">输入的关键词</param>
        /// <param name="pageNum"></param>
        /// <param name="size"></param>
        /// <param name="FileType">空间类型</param>
        /// <param name="ID">空间ID，用户ID</param>
        /// <returns></returns>
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public Folder GetFolderFromDBAndKeyWord(string path, string keyword, int pageNum, int size, string FileType, string ID)
        {

            int id = 0;
            if (path == "~/")
            {
                id = 0;
            }
            else
            {
                id = (int)Convert.ToSingle(path);
            }
            string strId = id.ToString();
            int folderSize = 0;
            Folder di = new Folder();//new Folder(physicalPath, GetBasePath(), config.Language);
            try
            {
                #region 项目库文件查询
                if (FileType == "XMK")
                {
                    Tb_Xmk_FileBiz fileBiz = new Tb_Xmk_FileBiz();
                    TB_Tree_ObjectBiz objBiz = new TB_Tree_ObjectBiz();
                    List<TB_Tree_ObjectInfo> objInfos = objBiz.QueryChildObjectByIdAndKeyWord(id, keyword, TreeType.XMK);  //FileHelper.GetFolderList(physicalPath, GetBasePath());
                    List<Folder> folders = new List<Folder>();
                    di.Folders = new List<Folder>();
                    int startFolderIndex = (pageNum - 1) * size;
                    int endFolderIndex = (pageNum) * size;
                    if (endFolderIndex > objInfos.Count)
                    {
                        endFolderIndex = objInfos.Count;
                    }

                    for (int i = startFolderIndex; i < endFolderIndex; i++)
                    {
                        TB_Tree_ObjectInfo obj = objInfos[i];
                        Folder folder = new Folder();
                        folder.Exists = true;
                        folder.Name = obj.ObjectName;
                        folder.Attributes = "Directory";
                        folder.IsArchive = false;
                        folder.LastModified = Convert.ToDateTime(obj.CreateTime);
                        folder.LastAccessed = Convert.ToDateTime(obj.CreateTime);
                        // folder.
                        folder.Size = 0;
                        //存储父节点id，用于项目库返回操作
                        folder.Attributes = Convert.ToString(obj.PObjectID);
                        folder.Created = Convert.ToDateTime(obj.CreateTime);
                        folder.IsWritable = true;
                        folder.RelativePath = obj.ObjectID.ToString();
                        folder.FileCount = fileBiz.GetCountByDestObjAndKeyWord(obj.ObjectID.ToString(), keyword);
                        folder.FolderCount = objBiz.GetChildCountByIdAndKeyWord(obj.ObjectID, keyword);
                        folder.Permission = "<table class='fe-permissions'><thead><tr><th>Uesr</th><th>whether to allow</th><th>right</th></tr></thead><tbody><tr><td>BUILTIN\\Administrators</td><td>Allow</td><td>FullControl</td></tr><tr><td>BUILTIN\\Administrators</td><td>Allow</td><td>268435456</td></tr><tr><td>NT AUTHORITY\\SYSTEM</td><td>Allow</td><td>FullControl</td></tr><tr><td>NT AUTHORITY\\SYSTEM</td><td>Allow</td><td>268435456</td></tr><tr><td>NT AUTHORITY\\Authenticated Users</td><td>Allow</td><td>Modify, Synchronize</td></tr><tr><td>NT AUTHORITY\\Authenticated Users</td><td>Allow</td><td>-536805376</td></tr><tr><td>BUILTIN\\Users</td><td>Allow</td><td>ReadAndExecute, Synchronize</td></tr><tr><td>BUILTIN\\Users</td><td>Allow</td><td>-1610612736</td></tr></tbody></table>";
                        di.Folders.Add(folder);
                        di.FolderCount += 1;
                        folderSize++;
                    }

                    di.Files = new List<FolderFile>();

                    int startNum = (pageNum - 1) * size;
                    int endNum = pageNum * size - objInfos.Count;
                    int total = 0;
                    if (startNum != 0)
                    {
                        startNum -= objInfos.Count;
                    }
                    DataTable dt_xmk_file = fileBiz.GetModelByDestObjAndKeyWord(strId, keyword, startNum, endNum + 1, ref total);
                    di.FileCount = total + objInfos.Count;

                    foreach (DataRow dr in dt_xmk_file.Rows)
                    {
                        FolderFile file = new FolderFile();
                        string fileName = dr["FILE_NAME"].ToString();
                        file.Name = fileName;
                        file.RelativePath = dr["FILE_ID"].ToString();
                        if (!Convert.IsDBNull(dr["FILE_SIZE"]))
                        {
                            string strSize = Convert.ToString(dr["FILE_SIZE"]);
                            strSize = strSize.ToLower();
                            if (strSize.Contains('m'))
                            {
                                strSize = strSize.Replace("mb", "");
                                strSize = strSize.Replace('m', ' ');
                                file.Size = (int)(Convert.ToSingle(strSize.Trim()) * 1024 * 1024);
                            }
                            else if (strSize.Contains('k'))
                            {
                                strSize = strSize.Replace("kb", "");
                                strSize = strSize.Replace('k', ' ');
                                file.Size = (int)(Convert.ToSingle(strSize.Trim()) * 1024);
                            }
                            else
                            {
                                // file.Size = ;
                            }

                        }
                        file.LastModified = Convert.ToDateTime(dr["UPD_TIME"]);
                        file.Extension = fileName.Substring(fileName.LastIndexOf('.'));
                        di.Files.Add(file);
                    }
                }
                #endregion 项目库文件查询

                #region 个人空间文件查询

                if (FileType == "PERSON")
                {
                    TB_PERSON_FILEBiz fileBiz = new TB_PERSON_FILEBiz();
                    TB_Tree_ObjectBiz objBiz = new TB_Tree_ObjectBiz();
                    List<TB_Tree_ObjectInfo> objInfos = objBiz.PTQueryChildObjectByIdAndKeyWord(id, ID, "", "PERSON", keyword);  //FileHelper.GetFolderList(physicalPath, GetBasePath());
                    List<Folder> folders = new List<Folder>();
                    di.Folders = new List<Folder>();
                    int startFolderIndex = (pageNum - 1) * size;
                    int endFolderIndex = (pageNum) * size;
                    if (endFolderIndex > objInfos.Count)
                    {
                        endFolderIndex = objInfos.Count;
                    }

                    for (int i = startFolderIndex; i < endFolderIndex; i++)
                    {
                        TB_Tree_ObjectInfo obj = objInfos[i];
                        Folder folder = new Folder();
                        folder.Exists = true;
                        folder.Name = obj.ObjectName;
                        folder.Attributes = "Directory";
                        folder.IsArchive = false;
                        folder.LastModified = Convert.ToDateTime(obj.CreateTime);
                        folder.LastAccessed = Convert.ToDateTime(obj.CreateTime);
                        // folder.
                        folder.Size = 0;
                        //存储父节点id，用于项目库返回操作
                        folder.Attributes = Convert.ToString(obj.PObjectID);
                        folder.Created = Convert.ToDateTime(obj.CreateTime);
                        folder.IsWritable = true;
                        folder.RelativePath = obj.ObjectID.ToString();
                        folder.FileCount = fileBiz.GetCountByDestObjByKeyWord(obj.ObjectID.ToString(), keyword);
                        folder.FolderCount = objBiz.GetChildCountByIdAndKeyWord1(obj.ObjectID, ID, "", "PERSON", keyword);
                        folder.Permission = "<table class='fe-permissions'><thead><tr><th>Uesr</th><th>whether to allow</th><th>right</th></tr></thead><tbody><tr><td>BUILTIN\\Administrators</td><td>Allow</td><td>FullControl</td></tr><tr><td>BUILTIN\\Administrators</td><td>Allow</td><td>268435456</td></tr><tr><td>NT AUTHORITY\\SYSTEM</td><td>Allow</td><td>FullControl</td></tr><tr><td>NT AUTHORITY\\SYSTEM</td><td>Allow</td><td>268435456</td></tr><tr><td>NT AUTHORITY\\Authenticated Users</td><td>Allow</td><td>Modify, Synchronize</td></tr><tr><td>NT AUTHORITY\\Authenticated Users</td><td>Allow</td><td>-536805376</td></tr><tr><td>BUILTIN\\Users</td><td>Allow</td><td>ReadAndExecute, Synchronize</td></tr><tr><td>BUILTIN\\Users</td><td>Allow</td><td>-1610612736</td></tr></tbody></table>";
                        di.Folders.Add(folder);
                        di.FolderCount += 1;
                        folderSize++;
                    }


                    di.Files = new List<FolderFile>();

                    int startNum = (pageNum - 1) * size;
                    int endNum = pageNum * size - objInfos.Count;
                    int total = 0;
                    if (startNum != 0)
                    {
                        startNum -= objInfos.Count;
                    }
                    DataTable dt_xmk_file = fileBiz.GetModelByDestObjAndKeyWord(strId, startNum, endNum + 1, ID, keyword, ref total);
                    di.FileCount = total + objInfos.Count;

                    foreach (DataRow dr in dt_xmk_file.Rows)
                    {
                        FolderFile file = new FolderFile();
                        string fileName = dr["FILE_NAME"].ToString();
                        file.Name = fileName;
                        file.RelativePath = dr["FILE_ID"].ToString();
                        // di.FileCount += 1;
                        //file.Path = fileName;//dr["DEST_OBJ"].ToString();
                        if (!Convert.IsDBNull(dr["FILE_SIZE"]))
                        {
                            string strSize = Convert.ToString(dr["FILE_SIZE"]);
                            strSize = strSize.ToLower();
                            if (strSize.Contains('m'))
                            {
                                strSize = strSize.Replace("mb", "");
                                strSize = strSize.Replace('m', ' ');
                                file.Size = (int)(Convert.ToSingle(strSize.Trim()) * 1024 * 1024);
                            }
                            else if (strSize.Contains('k'))
                            {
                                strSize = strSize.Replace("kb", "");
                                strSize = strSize.Replace('k', ' ');
                                file.Size = (int)(Convert.ToSingle(strSize.Trim()) * 1024);
                            }
                            else
                            {
                                // file.Size = ;
                            }

                        }
                        file.LastModified = Convert.ToDateTime(dr["UPD_TIME"]);
                        file.Extension = fileName.Substring(fileName.LastIndexOf('.'));
                        di.Files.Add(file);
                    }
                }

                #endregion 个人空间文件查询

                #region 课题组文件查询

                if (FileType == "TEAM")
                {
                    string userId = Context.Request.Cookies["user_id"].Value;
                    TB_TEAM_FILEBiz fileBiz = new TB_TEAM_FILEBiz();
                    TB_Tree_ObjectBiz objBiz = new TB_Tree_ObjectBiz();
                    List<TB_Tree_ObjectInfo> objInfos = objBiz.PTQueryChildObjectByIdAndKeyWord(id, userId, ID, "TEAM", keyword);  //FileHelper.GetFolderList(physicalPath, GetBasePath());
                    List<Folder> folders = new List<Folder>();
                    di.Folders = new List<Folder>();
                    int startFolderIndex = (pageNum - 1) * size;
                    int endFolderIndex = (pageNum) * size;
                    if (endFolderIndex > objInfos.Count)
                    {
                        endFolderIndex = objInfos.Count;
                    }

                    for (int i = startFolderIndex; i < endFolderIndex; i++)
                    {
                        TB_Tree_ObjectInfo obj = objInfos[i];
                        Folder folder = new Folder();
                        folder.Exists = true;
                        folder.Name = obj.ObjectName;
                        folder.Attributes = "Directory";
                        folder.IsArchive = false;
                        folder.LastModified = Convert.ToDateTime(obj.CreateTime);
                        folder.LastAccessed = Convert.ToDateTime(obj.CreateTime);
                        // folder.
                        folder.Size = 0;
                        //存储父节点id，用于项目库返回操作
                        folder.Attributes = Convert.ToString(obj.PObjectID);
                        folder.Created = Convert.ToDateTime(obj.CreateTime);
                        folder.IsWritable = true;
                        folder.RelativePath = obj.ObjectID.ToString();
                        folder.FileCount = fileBiz.GetCountByDestObjByKeyWord(obj.ObjectID.ToString(), keyword);
                        folder.FolderCount = objBiz.GetChildCountByIdAndKeyWord1(obj.ObjectID, userId, ID, "TEAM", keyword);
                        folder.Permission = "<table class='fe-permissions'><thead><tr><th>Uesr</th><th>whether to allow</th><th>right</th></tr></thead><tbody><tr><td>BUILTIN\\Administrators</td><td>Allow</td><td>FullControl</td></tr><tr><td>BUILTIN\\Administrators</td><td>Allow</td><td>268435456</td></tr><tr><td>NT AUTHORITY\\SYSTEM</td><td>Allow</td><td>FullControl</td></tr><tr><td>NT AUTHORITY\\SYSTEM</td><td>Allow</td><td>268435456</td></tr><tr><td>NT AUTHORITY\\Authenticated Users</td><td>Allow</td><td>Modify, Synchronize</td></tr><tr><td>NT AUTHORITY\\Authenticated Users</td><td>Allow</td><td>-536805376</td></tr><tr><td>BUILTIN\\Users</td><td>Allow</td><td>ReadAndExecute, Synchronize</td></tr><tr><td>BUILTIN\\Users</td><td>Allow</td><td>-1610612736</td></tr></tbody></table>";
                        di.Folders.Add(folder);
                        di.FolderCount += 1;
                        folderSize++;
                    }


                    di.Files = new List<FolderFile>();

                    int startNum = (pageNum - 1) * size;
                    int endNum = pageNum * size - objInfos.Count;
                    int total = 0;
                    if (startNum != 0)
                    {
                        startNum -= objInfos.Count;
                    }
                    DataTable dt_xmk_file = fileBiz.GetModelByDestObjAndKeyWord(strId, startNum, endNum + 1, ID, userId, keyword, ref total);
                    di.FileCount = total + objInfos.Count;

                    foreach (DataRow dr in dt_xmk_file.Rows)
                    {
                        FolderFile file = new FolderFile();
                        string fileName = dr["FILE_NAME"].ToString();
                        file.Name = fileName;
                        file.RelativePath = dr["FILE_ID"].ToString();
                        // di.FileCount += 1;
                        //file.Path = fileName;//dr["DEST_OBJ"].ToString();
                        if (!Convert.IsDBNull(dr["FILE_SIZE"]))
                        {
                            string strSize = Convert.ToString(dr["FILE_SIZE"]);
                            strSize = strSize.ToLower();
                            if (strSize.Contains('m'))
                            {
                                strSize = strSize.Replace("mb", "");
                                strSize = strSize.Replace('m', ' ');
                                file.Size = (int)(Convert.ToSingle(strSize.Trim()) * 1024 * 1024);
                            }
                            else if (strSize.Contains('k'))
                            {
                                strSize = strSize.Replace("kb", "");
                                strSize = strSize.Replace('k', ' ');
                                file.Size = (int)(Convert.ToSingle(strSize.Trim()) * 1024);
                            }
                            else
                            {
                                // file.Size = ;
                            }

                        }
                        file.LastModified = Convert.ToDateTime(dr["UPD_TIME"]);
                        file.Extension = fileName.Substring(fileName.LastIndexOf('.'));
                        di.Files.Add(file);
                    }
                }

                #endregion 课题组文件查询
            }
            catch (Exception ex)
            {
                di.ErrorOccured = true;
                di.Error += ex.Message;
            }
            try
            {
            }
            catch (Exception ex)
            {
                di.Error += ex.Message;
            }
            di.RelativePath = strId;
            return di;
        }



        /// <summary>
        /// 文件夹信息  
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public Folder GetFolderFromDB(string op, string path, int pageNum, int size, string FileType, string ID)
        {

            int id = 0;
            if (path == "~/")
            {
                id = 0;
            }

            else if (path == null)
            {
                id = 0; 
            }
            else 
            {
                id = (int)Convert.ToSingle(path);
            }
            if (op == "mubiao")
            {
                op = "DEST_OBJ";
            }
            else if (op == "yewu")
            {
                op = "BIZ_OBJ";
            }
            else if (op == "date")
            {
                op = "CREATE_TIME";
            }
            else if (op == "daxiao")
            {
                op = "FILE_SIZE";
            }
            else if (op == "geshi")
            {
                op = "FILE_EXT";
            }
            string strId = id.ToString();
            int folderSize = 0;
            Folder di = new Folder();//new Folder(physicalPath, GetBasePath(), config.Language);
            try
            {
                #region 项目库文件查询
                if (FileType == "XMK")
                {
                    Tb_Xmk_FileBiz fileBiz = new Tb_Xmk_FileBiz();
                    TB_Tree_ObjectBiz objBiz = new TB_Tree_ObjectBiz();
                    List<TB_Tree_ObjectInfo> objInfos = objBiz.GetChildById(id, TreeType.XMK);  //FileHelper.GetFolderList(physicalPath, GetBasePath());
                    List<Folder> folders = new List<Folder>();
                    di.Folders = new List<Folder>();
                    int startFolderIndex = (pageNum - 1) * size;
                    int endFolderIndex = (pageNum) * size;
                    if (endFolderIndex > objInfos.Count)
                    {
                        endFolderIndex = objInfos.Count;
                    }

                    for (int i = startFolderIndex; i < endFolderIndex; i++)
                    {
                        TB_Tree_ObjectInfo obj = objInfos[i];
                        Folder folder = new Folder();
                        folder.Exists = true;
                        folder.Name = obj.ObjectName;
                        folder.Attributes = "Directory";
                        folder.IsArchive = false;
                        folder.LastModified = Convert.ToDateTime(obj.CreateTime);
                        folder.LastAccessed = Convert.ToDateTime(obj.CreateTime);
                        // folder.
                        folder.Size = 0;
                        //存储父节点id，用于项目库返回操作
                        folder.Attributes = Convert.ToString(obj.PObjectID);
                        folder.Created = Convert.ToDateTime(obj.CreateTime);
                        folder.IsWritable = true;
                        folder.RelativePath = obj.ObjectID.ToString();
                        folder.FileCount = fileBiz.GetCountByDestObj(obj.ObjectID.ToString());
                        folder.FolderCount = objBiz.GetChildCountById(obj.ObjectID);
                        folder.Permission = "<table class='fe-permissions'><thead><tr><th>Uesr</th><th>whether to allow</th><th>right</th></tr></thead><tbody><tr><td>BUILTIN\\Administrators</td><td>Allow</td><td>FullControl</td></tr><tr><td>BUILTIN\\Administrators</td><td>Allow</td><td>268435456</td></tr><tr><td>NT AUTHORITY\\SYSTEM</td><td>Allow</td><td>FullControl</td></tr><tr><td>NT AUTHORITY\\SYSTEM</td><td>Allow</td><td>268435456</td></tr><tr><td>NT AUTHORITY\\Authenticated Users</td><td>Allow</td><td>Modify, Synchronize</td></tr><tr><td>NT AUTHORITY\\Authenticated Users</td><td>Allow</td><td>-536805376</td></tr><tr><td>BUILTIN\\Users</td><td>Allow</td><td>ReadAndExecute, Synchronize</td></tr><tr><td>BUILTIN\\Users</td><td>Allow</td><td>-1610612736</td></tr></tbody></table>";
                        di.Folders.Add(folder);
                        di.FolderCount += 1;
                        folderSize++;
                    }

                    //foreach (TB_Tree_ObjectInfo obj in objInfos)
                    //{
                    //    Folder folder = new Folder();
                    //    folder.Exists = true;
                    //    folder.Name = obj.ObjectName;
                    //    folder.Attributes = "Directory";
                    //    folder.IsArchive = false;
                    //    folder.LastModified = Convert.ToDateTime(obj.UpdateTime);
                    //    folder.LastAccessed = Convert.ToDateTime(obj.UpdateTime);
                    //    folder.Size = 0;
                    //    //存储父节点id，用于项目库返回操作
                    //    folder.Attributes =Convert.ToString(obj.PObjectID);
                    //    folder.Created = Convert.ToDateTime(obj.CreateTime);
                    //    folder.IsWritable = true;
                    //    folder.RelativePath = obj.ObjectID.ToString();
                    //    folder.Permission = "<table class='fe-permissions'><thead><tr><th>用户</th><th>是否允许</th><th>权限</th></tr></thead><tbody><tr><td>BUILTIN\\Administrators</td><td>Allow</td><td>FullControl</td></tr><tr><td>BUILTIN\\Administrators</td><td>Allow</td><td>268435456</td></tr><tr><td>NT AUTHORITY\\SYSTEM</td><td>Allow</td><td>FullControl</td></tr><tr><td>NT AUTHORITY\\SYSTEM</td><td>Allow</td><td>268435456</td></tr><tr><td>NT AUTHORITY\\Authenticated Users</td><td>Allow</td><td>Modify, Synchronize</td></tr><tr><td>NT AUTHORITY\\Authenticated Users</td><td>Allow</td><td>-536805376</td></tr><tr><td>BUILTIN\\Users</td><td>Allow</td><td>ReadAndExecute, Synchronize</td></tr><tr><td>BUILTIN\\Users</td><td>Allow</td><td>-1610612736</td></tr></tbody></table>";
                    //    di.Folders.Add(folder);
                    //    di.FolderCount += 1;
                    //}
                    //folderSize = di.FolderCount;
                    //               List<FolderFile> files = FileHelper.GetFileList(physicalPath, GetBasePath());
                    di.Files = new List<FolderFile>();

                    int startNum = (pageNum - 1) * size;
                    int endNum = pageNum * size - objInfos.Count;
                    int total = 0;
                    if (startNum != 0)
                    {
                        startNum -= objInfos.Count;
                    }
                    DataTable dt_xmk_file = fileBiz.GetModelByDestObjAndType(op, strId, startNum, endNum + 1, ref total);
                    di.FileCount = total + objInfos.Count;

                    foreach (DataRow dr in dt_xmk_file.Rows)
                    {
                        FolderFile file = new FolderFile();
                        string fileName = dr["FILE_NAME"].ToString();
                        file.Name = fileName;
                        file.RelativePath = dr["FILE_ID"].ToString();
                        // di.FileCount += 1;
                        //file.Path = fileName;//dr["DEST_OBJ"].ToString();
                        if (!Convert.IsDBNull(dr["FILE_SIZE"]))
                        {
                            string strSize = Convert.ToString(dr["FILE_SIZE"]);
                            strSize = strSize.ToLower();
                            if (strSize.Contains('m'))
                            {
                                strSize = strSize.Replace("mb", "");
                                strSize = strSize.Replace('m', ' ');
                                file.Size = (int)(Convert.ToSingle(strSize.Trim()) * 1024 * 1024 + 1);
                            }
                            else if (strSize.Contains('k'))
                            {
                                strSize = strSize.Replace("kb", "");
                                strSize = strSize.Replace('k', ' ');
                                file.Size = (int)(Convert.ToSingle(strSize.Trim()) * 1024 + 1);
                            }
                            else
                            {
                                // file.Size = ;
                            }

                        }
                        file.LastModified = Convert.ToDateTime(dr["UPD_TIME"]);
                        file.Extension = fileName.Substring(fileName.LastIndexOf('.'));
                        di.Files.Add(file);
                    }

                    //foreach (FolderFile f in files)
                    //{
                    //    if (f.Extension.ToLower() == ".pdf" || f.Extension.ToLower() == ".swf")
                    //    {
                    //        continue;
                    //    }
                    //    if (Allowed(f.RelativePath, "r"))
                    //    {
                    //        di.Files.Add(f);
                    //    }
                    //}
                }
                #endregion 项目库文件查询



                #region 个人空间文件查询

                if (FileType == "PERSON")
                {
                    TB_PERSON_FILEBiz fileBiz = new TB_PERSON_FILEBiz();
                    TB_Tree_ObjectBiz objBiz = new TB_Tree_ObjectBiz();
                    List<TB_Tree_ObjectInfo> objInfos = objBiz.QueryChildObjectById(id, ID, "", "PERSON");  //FileHelper.GetFolderList(physicalPath, GetBasePath());
                    List<Folder> folders = new List<Folder>();
                    di.Folders = new List<Folder>();
                    int startFolderIndex = (pageNum - 1) * size;
                    int endFolderIndex = (pageNum) * size;
                    if (endFolderIndex > objInfos.Count)
                    {
                        endFolderIndex = objInfos.Count;
                    }

                    for (int i = startFolderIndex; i < endFolderIndex; i++)
                    {
                        TB_Tree_ObjectInfo obj = objInfos[i];
                        Folder folder = new Folder();
                        folder.Exists = true;
                        folder.Name = obj.ObjectName;
                        folder.Attributes = "Directory";
                        folder.IsArchive = false;
                        folder.LastModified = Convert.ToDateTime(obj.CreateTime);
                        folder.LastAccessed = Convert.ToDateTime(obj.CreateTime);
                        // folder.
                        folder.Size = 0;
                        //存储父节点id，用于项目库返回操作
                        folder.Attributes = Convert.ToString(obj.PObjectID);
                        folder.Created = Convert.ToDateTime(obj.CreateTime);
                        folder.IsWritable = true;
                        folder.RelativePath = obj.ObjectID.ToString();
                        folder.FileCount = fileBiz.GetCountByDestObj(obj.ObjectID.ToString());
                        folder.FolderCount = objBiz.GetChildCountById1(obj.ObjectID, ID, "", "PERSON");
                        folder.Permission = "<table class='fe-permissions'><thead><tr><th>用户</th><th>是否允许</th><th>权限</th></tr></thead><tbody><tr><td>BUILTIN\\Administrators</td><td>Allow</td><td>FullControl</td></tr><tr><td>BUILTIN\\Administrators</td><td>Allow</td><td>268435456</td></tr><tr><td>NT AUTHORITY\\SYSTEM</td><td>Allow</td><td>FullControl</td></tr><tr><td>NT AUTHORITY\\SYSTEM</td><td>Allow</td><td>268435456</td></tr><tr><td>NT AUTHORITY\\Authenticated Users</td><td>Allow</td><td>Modify, Synchronize</td></tr><tr><td>NT AUTHORITY\\Authenticated Users</td><td>Allow</td><td>-536805376</td></tr><tr><td>BUILTIN\\Users</td><td>Allow</td><td>ReadAndExecute, Synchronize</td></tr><tr><td>BUILTIN\\Users</td><td>Allow</td><td>-1610612736</td></tr></tbody></table>";
                        di.Folders.Add(folder);
                        di.FolderCount += 1;
                        folderSize++;
                    }


                    di.Files = new List<FolderFile>();

                    int startNum = (pageNum - 1) * size;
                    int endNum = pageNum * size - objInfos.Count;
                    int total = 0;
                    if (startNum != 0)
                    {
                        startNum -= objInfos.Count;
                    }
                    //DataTable dt_xmk_file = fileBiz.GetModelByDestObj(strId, startNum, endNum + 1, ID, ref total);
                    DataTable dt_xmk_file = fileBiz.GetModelByDestObjAndType(strId, op, startNum, endNum + 1, ID, ref total);
                    di.FileCount = total + objInfos.Count;

                    foreach (DataRow dr in dt_xmk_file.Rows)
                    {
                        FolderFile file = new FolderFile();
                        string fileName = dr["FILE_NAME"].ToString();
                        file.Name = fileName;
                        file.RelativePath = dr["FILE_ID"].ToString();
                        // di.FileCount += 1;
                        //file.Path = fileName;//dr["DEST_OBJ"].ToString();
                        if (!Convert.IsDBNull(dr["FILE_SIZE"]))
                        {
                            string strSize = Convert.ToString(dr["FILE_SIZE"]);
                            strSize = strSize.ToLower();
                            if (strSize.Contains('m'))
                            {
                                strSize = strSize.Replace("mb", "");
                                strSize = strSize.Replace('m', ' ');
                                file.Size = (int)(Convert.ToSingle(strSize.Trim()) * 1024 * 1024 + 1);
                            }
                            else if (strSize.Contains('k'))
                            {
                                strSize = strSize.Replace("kb", "");
                                strSize = strSize.Replace('k', ' ');
                                file.Size = (int)(Convert.ToSingle(strSize.Trim()) * 1024 + 1);
                            }
                            else
                            {
                                // file.Size = ;
                            }

                        }
                        file.LastModified = Convert.ToDateTime(dr["UPD_TIME"]);
                        file.Extension = fileName.Substring(fileName.LastIndexOf('.'));
                        di.Files.Add(file);
                    }
                }

                #endregion 个人空间文件查询

                #region 课题组文件查询

                if (FileType == "TEAM")
                {
                    string userId = Context.Request.Cookies["user_id"].Value;
                    TB_TEAM_FILEBiz fileBiz = new TB_TEAM_FILEBiz();
                    TB_Tree_ObjectBiz objBiz = new TB_Tree_ObjectBiz();
                    List<TB_Tree_ObjectInfo> objInfos = objBiz.QueryChildObjectById(id, userId, ID, "TEAM");  //FileHelper.GetFolderList(physicalPath, GetBasePath());
                    List<Folder> folders = new List<Folder>();
                    di.Folders = new List<Folder>();
                    int startFolderIndex = (pageNum - 1) * size;
                    int endFolderIndex = (pageNum) * size;
                    if (endFolderIndex > objInfos.Count)
                    {
                        endFolderIndex = objInfos.Count;
                    }

                    for (int i = startFolderIndex; i < endFolderIndex; i++)
                    {
                        TB_Tree_ObjectInfo obj = objInfos[i];
                        Folder folder = new Folder();
                        folder.Exists = true;
                        folder.Name = obj.ObjectName;
                        folder.Attributes = "Directory";
                        folder.IsArchive = false;
                        folder.LastModified = Convert.ToDateTime(obj.CreateTime);
                        folder.LastAccessed = Convert.ToDateTime(obj.CreateTime);
                        // folder.
                        folder.Size = 0;
                        //存储父节点id，用于项目库返回操作
                        folder.Attributes = Convert.ToString(obj.PObjectID);
                        folder.Created = Convert.ToDateTime(obj.CreateTime);
                        folder.IsWritable = true;
                        folder.RelativePath = obj.ObjectID.ToString();
                        folder.FileCount = fileBiz.GetCountByDestObj(obj.ObjectID.ToString());
                        folder.FolderCount = objBiz.GetChildCountById1(obj.ObjectID, userId, ID, "TEAM");
                        folder.Permission = "<table class='fe-permissions'><thead><tr><th>用户</th><th>是否允许</th><th>权限</th></tr></thead><tbody><tr><td>BUILTIN\\Administrators</td><td>Allow</td><td>FullControl</td></tr><tr><td>BUILTIN\\Administrators</td><td>Allow</td><td>268435456</td></tr><tr><td>NT AUTHORITY\\SYSTEM</td><td>Allow</td><td>FullControl</td></tr><tr><td>NT AUTHORITY\\SYSTEM</td><td>Allow</td><td>268435456</td></tr><tr><td>NT AUTHORITY\\Authenticated Users</td><td>Allow</td><td>Modify, Synchronize</td></tr><tr><td>NT AUTHORITY\\Authenticated Users</td><td>Allow</td><td>-536805376</td></tr><tr><td>BUILTIN\\Users</td><td>Allow</td><td>ReadAndExecute, Synchronize</td></tr><tr><td>BUILTIN\\Users</td><td>Allow</td><td>-1610612736</td></tr></tbody></table>";
                        di.Folders.Add(folder);
                        di.FolderCount += 1;
                        folderSize++;
                    }


                    di.Files = new List<FolderFile>();

                    int startNum = (pageNum - 1) * size;
                    int endNum = pageNum * size - objInfos.Count;
                    int total = 0;
                    if (startNum != 0)
                    {
                        startNum -= objInfos.Count;
                    }
                    DataTable dt_xmk_file = fileBiz.GetModelByDestObjAndType(op, strId, startNum, endNum + 1, ID, userId, ref total);

                    di.FileCount = total + objInfos.Count;

                    foreach (DataRow dr in dt_xmk_file.Rows)
                    {
                        FolderFile file = new FolderFile();
                        string fileName = dr["FILE_NAME"].ToString();
                        file.Name = fileName;
                        file.RelativePath = dr["FILE_ID"].ToString();
                        // di.FileCount += 1;
                        //file.Path = fileName;//dr["DEST_OBJ"].ToString();
                        if (!Convert.IsDBNull(dr["FILE_SIZE"]))
                        {
                            string strSize = Convert.ToString(dr["FILE_SIZE"]);
                            strSize = strSize.ToLower();
                            if (strSize.Contains('m'))
                            {
                                strSize = strSize.Replace("mb", "");
                                strSize = strSize.Replace('m', ' ');
                                file.Size = (int)(Convert.ToSingle(strSize.Trim()) * 1024 * 1024 + 1);
                            }
                            else if (strSize.Contains('k'))
                            {
                                strSize = strSize.Replace("kb", "");
                                strSize = strSize.Replace('k', ' ');
                                file.Size = (int)(Convert.ToSingle(strSize.Trim()) * 1024 + 1);
                            }
                            else
                            {
                                // file.Size = ;
                            }

                        }
                        file.LastModified = Convert.ToDateTime(dr["UPD_TIME"]);
                        file.Extension = fileName.Substring(fileName.LastIndexOf('.'));
                        di.Files.Add(file);
                    }
                }

                #endregion 课题组文件查询
            }
            catch (Exception ex)
            {
                di.ErrorOccured = true;
                di.Error += ex.Message;
            }
            try
            {
                //制造一些缩略图
                //  ThumbnailHelper.GenerateThumbnailsInFolder(physicalPath, GetBasePath(), Server.MapPath(GetThumbPath()));
            }
            catch (Exception ex)
            {
                //缩略图错误不算错误。。。
                //di.ErrorOccured = true;
                di.Error += ex.Message;
            }
            di.RelativePath = strId;
            return di;
        }

        /// <summary>
        /// 当前课题组共享文件信息  GetShareView
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public List<shareFileItem> GetShareView(string groupName, string sorttype, string sortdesc, int pageNum, int size)
        {
            int startNum = (pageNum - 1) * size;
            int endNum = pageNum * size;//- objInfos.Count;
            int total = 0;
            Tb_Person_File_ShareBiz bll = new Tb_Person_File_ShareBiz();
            DataTable dt = bll.getShareFileInfoByTeamName(groupName,sorttype,sortdesc, startNum, endNum + 1, ref total);
            //存放共享数据列表
            List<shareFileItem> items = new List<shareFileItem>();
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                shareFileItem item = new shareFileItem();
                item.FILE_ID = dt.Rows[i]["FILE_ID"].ToString();
                item.FILE_NAME = dt.Rows[i]["FILE_NAME"].ToString();
                item.USER_NAME = dt.Rows[i]["USER_NAME"].ToString();
                item.CREATE_TIME = (Convert.ToDateTime(dt.Rows[i]["CREATE_TIME"].ToString())).ToShortDateString();
                item.UPD_TIME = (Convert.ToDateTime(dt.Rows[i]["UPD_TIME"].ToString())).ToShortDateString();
                item.FileCount = total;
                item.Extension = item.FILE_NAME.Substring(item.FILE_NAME.LastIndexOf("."));
                items.Add(item);

            }
            return items;

        }
        /// <summary>
        /// 项目库共享文件信息  GetXmkShareView
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public List<shareFileItem> GetXmkShareView(int pageNum, string sorttype, string sortdesc, int size)
        {
            int startNum = (pageNum - 1) * size;
            int endNum = pageNum * size;//- objInfos.Count;
            int total = 0;
            Tb_Person_File_ShareBiz bll = new Tb_Person_File_ShareBiz();
            DataTable dt = bll.getXmkShareFileInfo(startNum, sorttype, sortdesc,endNum + 1, ref  total);
            //存放共享数据列表
            List<shareFileItem> items = new List<shareFileItem>();
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                shareFileItem item = new shareFileItem();
                item.FILE_ID = dt.Rows[i]["FILE_ID"].ToString();
                item.FILE_NAME = dt.Rows[i]["FILE_NAME"].ToString();
                item.USER_NAME = dt.Rows[i]["USER_NAME"].ToString();
                item.CREATE_TIME = (Convert.ToDateTime(dt.Rows[i]["CREATE_TIME"].ToString())).ToShortDateString();
                item.UPD_TIME = (Convert.ToDateTime(dt.Rows[i]["UPD_TIME"].ToString())).ToShortDateString();
                item.FileCount = total;
                item.Extension = item.FILE_NAME.Substring(item.FILE_NAME.LastIndexOf("."));
                items.Add(item);

            }
            return items;

        }
        /// <summary>
        /// 当前用户共享文件信息  GetMyShareView
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public List<MyShareFileItem> GetMyShareView(string userId, string sorttype, string sortdesc, int pageNum, int size)
        {

            Tb_Person_File_ShareBiz bll = new Tb_Person_File_ShareBiz();
            int startNum = (pageNum - 1) * size;
            int endNum = pageNum * size;//- objInfos.Count;
            int total = 0;
            DataTable dt = bll.getShareFileInfoByUserId(userId,sorttype,sortdesc, startNum, endNum + 1, ref total);
            //存放共享数据列表
            List<MyShareFileItem> items = new List<MyShareFileItem>();
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                MyShareFileItem item = new MyShareFileItem();
                item.FILE_ID = dt.Rows[i]["FILE_ID"].ToString();
                item.SHARE_OBJ_ID = dt.Rows[i]["SHARE_OBJ_ID"].ToString();
                item.SHARE_OBJ_NAME = dt.Rows[i]["SHARE_OBJ_NAME"].ToString();
                item.FILE_NAME = dt.Rows[i]["FILE_NAME"].ToString();
                item.CREATE_TIME = (Convert.ToDateTime(dt.Rows[i]["CREATE_TIME"].ToString())).ToShortDateString();
                //item.UPD_TIME = (Convert.ToDateTime(dt.Rows[i]["UPD_TIME"].ToString())).ToShortDateString();
                item.FileCount = total;
                item.Extension = item.FILE_NAME.Substring(item.FILE_NAME.LastIndexOf("."));
                items.Add(item);

            }
            return items;

        }


        /// <summary>
        /// 我的提交  GetMySubmitData
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public List<MySubmitItem> GetMySubmitData(string UserID, string sorttype, string status,string sortdesc, int pageNum, int size)
        {
            TB_TEAM_FILEBiz bll = new TB_TEAM_FILEBiz();
            int startNum = (pageNum - 1) * size;
            int endNum = pageNum * size;//- objInfos.Count;
            int total = 0;
            DataTable dt = bll.GetMySubmitModel(UserID, sorttype, sortdesc, status,startNum, endNum + 1, ref total);
            //我的提交
            List<MySubmitItem> items = new List<MySubmitItem>();
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                MySubmitItem item = new MySubmitItem();
                item.FILE_ID = dt.Rows[i]["FILE_ID"].ToString();
                item.FILE_NAME = dt.Rows[i]["FILE_NAME"].ToString();
                //item.STATSU = dt.Rows[i]["STATSU"].ToString();
                item.CREATE_TIME = dt.Rows[i]["CREATE_TIME"].ToString();
                item.TEAM_NAME = dt.Rows[i]["TEAM_NAME"].ToString();
                item.FileCount = total;
                item.Extension = item.FILE_NAME.Substring(item.FILE_NAME.LastIndexOf("."));
                items.Add(item);

            }
            return items;

        }


        /// <summary>
        /// 个人空间获取回收站信息
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public List<RecycleItem> GetRecycleData(string User_ID, string sorttype, string sortdesc, int pageNum, int size)
        // public List<RecycleItem> GetRecycleData(string User_ID)
        {
            int startNum = (pageNum - 1) * size;
            int endNum = pageNum * size;//- objInfos.Count;
            int total = 0;

            //Tb_Xmk_FileBiz bll = new Tb_Xmk_FileBiz();
            TB_PERSON_FILEBiz bll = new TB_PERSON_FILEBiz();
            //DataTable dt = bll.GetRecycleDataBySql(User_ID);
            DataTable dt = bll.GetRecycleDataBySql(User_ID, sorttype, sortdesc, startNum, endNum + 1, ref total);
            List<RecycleItem> items = new List<RecycleItem>();
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                RecycleItem item = new RecycleItem();
                item.FILE_ID = dt.Rows[i]["FILE_ID"].ToString();
                item.FILE_NAME = dt.Rows[i]["FILE_NAME"].ToString();
                //item.SPACE_NAME = dt.Rows[i]["SPACE_NAME"].ToString();
                item.FILE_SIZE = dt.Rows[i]["FILE_SIZE"].ToString();
                item.RECYCLE_DATE = dt.Rows[i]["RECYCLE_DATE"].ToString();
                item.FileCount = total;
                item.Extension = item.FILE_NAME.Substring(item.FILE_NAME.LastIndexOf("."));
                items.Add(item);
            }
            return items;
        }
        /// <summary>
        /// 课题组空间获取回收站信息
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        //public List<RecycleItem> GetRecycleData(string User_ID, string status, int pageNum,int size)
        public List<RecycleItem> GetTeamRecycleData(string TeamID, string sorttype, string sortdesc, int pageNum, int size)
        {
            int startNum = (pageNum - 1) * size;
            int endNum = pageNum * size;//- objInfos.Count;
            int total = 0;

            TB_TEAM_FILEBiz bll = new TB_TEAM_FILEBiz();
            DataTable dt = bll.GetRecycleDataBySql(TeamID,sorttype,sortdesc, startNum, endNum + 1, ref total);
            List<RecycleItem> items = new List<RecycleItem>();
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                RecycleItem item = new RecycleItem();
                item.FILE_ID = dt.Rows[i]["FILE_ID"].ToString();
                item.FILE_NAME = dt.Rows[i]["FILE_NAME"].ToString();
                //item.SPACE_NAME = dt.Rows[i]["SPACE_NAME"].ToString();
                item.FILE_SIZE = dt.Rows[i]["FILE_SIZE"].ToString();
                item.RECYCLE_DATE = dt.Rows[i]["RECYCLE_DATE"].ToString();
                item.FileCount = total;
                item.Extension = item.FILE_NAME.Substring(item.FILE_NAME.LastIndexOf("."));
                items.Add(item);
            }
            return items;
        }

        /// <summary>
        /// 项目库空间获取回收站信息
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        //public List<RecycleItem> GetRecycleData(string User_ID, string status, int pageNum,int size)
        public List<RecycleItem> GetProjectRecycleData(int pageNum, string sorttype, string sortdesc, int size)
        {
            int startNum = (pageNum - 1) * size;
            int endNum = pageNum * size;//- objInfos.Count;
            int total = 0;
            Tb_Xmk_FileBiz bll = new Tb_Xmk_FileBiz();
            DataTable dt = bll.GetRecycleDataBySql(startNum, sorttype, sortdesc,endNum + 1, ref total);
            List<RecycleItem> items = new List<RecycleItem>();
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                RecycleItem item = new RecycleItem();
                item.FILE_ID = dt.Rows[i]["FILE_ID"].ToString();
                item.FILE_NAME = dt.Rows[i]["FILE_NAME"].ToString();
                //item.SPACE_NAME = dt.Rows[i]["SPACE_NAME"].ToString();
                item.FILE_SIZE = dt.Rows[i]["FILE_SIZE"].ToString();
                item.RECYCLE_DATE = dt.Rows[i]["RECYCLE_DATE"].ToString();
                item.FileCount = total;
                item.Extension = item.FILE_NAME.Substring(item.FILE_NAME.LastIndexOf("."));
                items.Add(item);
            }
            return items;
        }

        /// <summary>
        /// 获取该用户下的课题组
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public List<MySubmitItem> GetTeamData(string user_id)
        {
            Tb_Team_UserBiz team_userBiz = new Tb_Team_UserBiz();
            JsonResponse response = new JsonResponse();

            List<MySubmitItem> items = new List<MySubmitItem>();
            user_id = user_id.Replace(" ", "");
            List<Base_UserSpaceInfo> spaces = team_userBiz.GetSpaceListByUserId(user_id);
            for (int i = 0; i < spaces.Count; i++)
            {
                if (spaces[i].IsOpen && spaces[i].SpaceId != "17")//项目库id固定，不能更改
                {
                    MySubmitItem item = new MySubmitItem();
                    item.TEAM_ID = spaces[i].SpaceId;
                    item.TEAM_NAME = spaces[i].SpaceName;
                    items.Add(item);
                }

            }

            return items;

        }


        /// <summary>
        /// 批量将文件提交
        /// </summary>
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public JsonResponse DatasToBubmit(string FILE_ID, string TEAM_ID, string spaceType, string SpaceName)
        {
            JsonResponse response = new JsonResponse();
            response.success = false;
            //FILE_ID = FILE_ID.TrimEnd(',');
            FILE_ID = FILE_ID.Remove(FILE_ID.LastIndexOf(","), 1);


            //提交至文件夹按照日期创建
            string FolderName = System.DateTime.Now.ToString("yyyyMMdd");
            string DiskPath = ConfigurationManager.AppSettings["DiskPath"];
            try
            {

                if (spaceType == "individual")
                {
                    string N_P_SOU_PATH = "";
                    string N_P_SWF_PATH = "";
                    string N_P_PDF_PATH = "";
                    TEAM_ID = TEAM_ID.Remove(TEAM_ID.LastIndexOf(","), 1);
                    string[] fileids = FILE_ID.Split(',');
                    string[] teamids = TEAM_ID.Split(',');
                    TB_TEAM_FILEInfo model;
                    TB_TEAM_FILEBiz bll = new TB_TEAM_FILEBiz();
                    TB_PERSON_FILEBiz pbll = new TB_PERSON_FILEBiz();
                    DataTable dt = pbll.GetModelList(FILE_ID);
                    string NewFileName;
                    if (dt.Rows.Count > 0)
                    {
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            for (int j = 0; j < teamids.Length; j++)
                            {
                                if (teamids.Length == 1)
                                {
                                    NewFileName = DateTime.Now.ToFileTimeUtc().ToString() + i.ToString();
                                }
                                else
                                {
                                    NewFileName = DateTime.Now.ToFileTimeUtc().ToString() + j.ToString();
                                }
                                string save_name = dt.Rows[i]["SAVE_PATH"].ToString().Substring(dt.Rows[i]["SAVE_PATH"].ToString().LastIndexOf("/") + 1);
                                model = new TB_TEAM_FILEInfo();
                                model.TEAM_ID = int.Parse(teamids[j]);
                                model.FILE_NAME = dt.Rows[i]["FILE_NAME"].ToString();
                                model.FILE_EXT = dt.Rows[i]["FILE_EXT"].ToString();
                                model.FILE_ABST = dt.Rows[i]["FILE_ABST"].ToString();
                                model.FILE_AUTHOR = dt.Rows[i]["FILE_AUTHOR"].ToString();
                                model.KEYW = dt.Rows[i]["KEYW"].ToString();
                                model.FILE_CRT_TIME = Convert.ToDateTime(dt.Rows[i]["FILE_CRT_DATE"].ToString());
                                model.FILE_SIZE = dt.Rows[i]["FILE_SIZE"].ToString();
                                model.DOWN_AMOUNT = 0;
                                model.DEST_OBJ = dt.Rows[i]["DEST_OBJ"].ToString();
                                model.BIZ_OBJ = dt.Rows[i]["BIZ_OBJ"].ToString();
                                model.SECRET_LVL = "";
                                model.LANG_TYPE = Convert.ToDecimal(dt.Rows[i]["LANG_TYPE"].ToString());
                                model.FILE_TYPE = dt.Rows[i]["FILE_TYPE"].ToString();
                                model.USER_ID = dt.Rows[i]["USER_ID"].ToString();
                                model.STATUS = 0;
                                model.CREATE_TIME = Convert.ToDateTime(System.DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"));
                                model.UPD_TIME = Convert.ToDateTime(System.DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"));
                                model.SINGLERECEIPT = "";
                                model.FILE_VERSION = bll.GetMaxFileTeam(model.FILE_NAME, model.TEAM_ID.ToString()) + 1;

                                //新文件名
                                N_P_SOU_PATH = "Group/" + FolderName + "/" + NewFileName + model.FILE_NAME.Substring(model.FILE_NAME.LastIndexOf("."));

                                //swf文件
                                if (!string.IsNullOrEmpty(dt.Rows[i]["SWF_PATH"].ToString()))
                                {
                                    N_P_SWF_PATH = "SWF/Group/" + FolderName + "/" + NewFileName + "/";
                                }
                                //pdf文件
                                if (!string.IsNullOrEmpty(dt.Rows[i]["PDF_PATH"].ToString()))
                                {
                                    N_P_PDF_PATH = "PDF/Group/" + FolderName + "/" + NewFileName + ".pdf";
                                }
                                model.SAVE_PATH = N_P_SOU_PATH;
                                model.PDF_PATH = N_P_PDF_PATH;
                                model.SWF_PATH = N_P_SWF_PATH;
                                model.FOLDER_ID = "0";
                                //数据添加成功复制文件
                                if (bll.Add(model))
                                {
                                    string T_PATH = "Group/" + FolderName;
                                    string g_PATH = DiskPath + T_PATH;
                                    if (!Directory.Exists(g_PATH))
                                        Directory.CreateDirectory(g_PATH);

                                    //原文件
                                    string SourFile = DiskPath + dt.Rows[i]["SAVE_PATH"].ToString();
                                    FileHelper.CopyFile1(SourFile, DiskPath + N_P_SOU_PATH);

                                    //swf文件
                                    if (!string.IsNullOrEmpty(dt.Rows[i]["SWF_PATH"].ToString()))
                                    {
                                        if (!Directory.Exists(DiskPath + "SWF/Group/" + FolderName + "/" + NewFileName))
                                            Directory.CreateDirectory(DiskPath + "SWF/Group/" + FolderName + "/" + NewFileName);

                                        CopyFile(DiskPath + dt.Rows[i]["SWF_PATH"].ToString(), DiskPath + N_P_SWF_PATH);
                                    }
                                    //pdf文件
                                    if (!string.IsNullOrEmpty(dt.Rows[i]["PDF_PATH"].ToString()))
                                    {
                                        if (!Directory.Exists(DiskPath + "PDF/Group/" + FolderName))
                                            Directory.CreateDirectory(DiskPath + "PDF/Group/" + FolderName);
                                        FileHelper.CopyFile1(DiskPath + dt.Rows[i]["PDF_PATH"].ToString(), DiskPath + N_P_PDF_PATH);
                                    }
                                }
                            }
                        }
                    }



                }
                else if (spaceType == "group")
                {
                    string N_X_SOU_PATH = "";
                    string N_X_SWF_PATH = "";
                    string N_X_PDF_PATH = "";
                    string[] fileids = FILE_ID.Split(',');
                    Tb_Xmk_FileBiz biz = new Tb_Xmk_FileBiz();
                    TB_XMK_FILEInfo model;
                    TB_TEAM_FILEBiz Tbll = new TB_TEAM_FILEBiz();
                    DataTable tdt = Tbll.GetModelList(FILE_ID);
                    if (tdt.Rows.Count > 0)
                    {
                        for (int i = 0; i < tdt.Rows.Count; i++)
                        {
                            string NewFileName = DateTime.Now.ToFileTimeUtc().ToString() + i.ToString();
                            string save_name = tdt.Rows[i]["SAVE_PATH"].ToString().Substring(tdt.Rows[i]["SAVE_PATH"].ToString().LastIndexOf("/") + 1);
                            model = new TB_XMK_FILEInfo();
                            model.TEAM_ID = Convert.ToDecimal(tdt.Rows[i]["TEAM_ID"].ToString());
                            model.FILE_NAME = tdt.Rows[i]["FILE_NAME"].ToString();
                            model.FILE_EXT = tdt.Rows[i]["FILE_EXT"].ToString();
                            model.FILE_ABST = tdt.Rows[i]["FILE_ABST"].ToString();
                            model.FILE_AUTHOR = tdt.Rows[i]["FILE_AUTHOR"].ToString();
                            model.KEYW = tdt.Rows[i]["KEYW"].ToString();
                            model.FILE_CRT_DATE = Convert.ToDateTime(tdt.Rows[i]["FILE_CRT_TIME"].ToString());
                            model.FILE_VERSION = Convert.ToDecimal(tdt.Rows[i]["FILE_VERSION"].ToString());
                            model.FILE_SIZE = tdt.Rows[i]["FILE_SIZE"].ToString();
                            model.DOWN_AMOUNT = Convert.ToDecimal(tdt.Rows[i]["DOWN_AMOUNT"].ToString());
                            model.DEST_OBJ = tdt.Rows[i]["DEST_OBJ"].ToString();
                            model.BIZ_OBJ = tdt.Rows[i]["BIZ_OBJ"].ToString();
                            model.SECRET_LVL = tdt.Rows[i]["SECRET_LVL"].ToString();
                            model.LANG_TYPE = Convert.ToDecimal(tdt.Rows[i]["LANG_TYPE"].ToString());
                            model.FILE_TYPE = tdt.Rows[i]["FILE_TYPE"].ToString();
                            model.FILE_VERSION = biz.GetMaxFileVersionXmk(model.FILE_NAME) + 1;
                            //新文件名
                            N_X_SOU_PATH = "Project/" + FolderName + "/" + NewFileName + model.FILE_NAME.Substring(model.FILE_NAME.LastIndexOf("."));
                            //pdf文件
                            if (!string.IsNullOrEmpty(tdt.Rows[i]["PDF_PATH"].ToString()))
                            {
                                N_X_PDF_PATH = "PDF/Project/" + FolderName + "/" + NewFileName + ".pdf";
                            }
                            //swf文件
                            if (!string.IsNullOrEmpty(tdt.Rows[i]["SWF_PATH"].ToString()))
                            {
                                N_X_SWF_PATH = "SWF/Project/" + FolderName + "/" + NewFileName + "/";
                            }

                            model.SAVE_PATH = N_X_SOU_PATH;
                            model.PDF_PATH = N_X_PDF_PATH;
                            model.SWF_PATH = N_X_SWF_PATH;
                            model.USER_ID = tdt.Rows[i]["USER_ID"].ToString();
                            model.STATUS = 0;
                            model.CREATE_TIME = Convert.ToDateTime(System.DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"));
                            model.UPD_TIME = Convert.ToDateTime(System.DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"));
                            model.FOLDER_ID = Convert.ToDecimal(0);
                            model.TEAM_NAME = SpaceName.Trim().ToString();//来源项目
                            if (tdt.Rows[i]["SHARED_SCOPE_ID"].ToString() != "")
                            {
                                model.SHARED_SCOPE_ID = tdt.Rows[i]["SHARED_SCOPE_ID"].ToString();//使用范围
                            }
                            //获取所属单位，根据当前用户id，找到其所属组织级别为“单位”的组织名称，如果没找到，则为空
                            Base_OrganizationBiz OrgBiz = new Base_OrganizationBiz();
                            DataTable orgnamedt = OrgBiz.getOrgNameByUserId();
                            if (orgnamedt != null && orgnamedt.Rows.Count>0)
                            {
                                model.FORM_UNIT = orgnamedt.Rows[0][0].ToString();
                            }
                            else
                            {
                                model.FORM_UNIT = "";
                            }


                            if (biz.Add(model))
                            {
                                string P_PATH = DiskPath + "Project/" + FolderName;
                                if (!Directory.Exists(P_PATH))
                                    Directory.CreateDirectory(P_PATH);
                                //原文件
                                string SourFile = DiskPath + tdt.Rows[i]["SAVE_PATH"].ToString();
                                FileHelper.CopyFile1(SourFile, DiskPath + N_X_SOU_PATH);

                                //swf文件
                                if (!string.IsNullOrEmpty(tdt.Rows[i]["SWF_PATH"].ToString()))
                                {
                                    if (!Directory.Exists(DiskPath + "SWF/Project/" + FolderName + "/" + NewFileName))
                                        Directory.CreateDirectory(DiskPath + "SWF/Project/" + FolderName + "/" + NewFileName);

                                    CopyFile(DiskPath + tdt.Rows[i]["SWF_PATH"].ToString(), DiskPath + N_X_SWF_PATH);
                                }
                                //pdf文件
                                if (!string.IsNullOrEmpty(tdt.Rows[i]["PDF_PATH"].ToString()))
                                {
                                    if (!Directory.Exists(DiskPath + "PDF/Project/" + FolderName))
                                        Directory.CreateDirectory(DiskPath + "PDF/Project/" + FolderName);
                                    FileHelper.CopyFile1(DiskPath + tdt.Rows[i]["PDF_PATH"].ToString(), DiskPath + N_X_PDF_PATH);
                                }

                            }
                        }
                    }
                }
                response.message = lang_server.Get("SPACE_submit_success");
                response.success = true;
            }
            catch (Exception ex)
            {
                response.success = false;
            }
            return response;
        }

        private void CopyFile(string sources, string dest)
        {
            DirectoryInfo dinfo = new DirectoryInfo(sources);//注，这里面传的是路径，并不是文件，所以不能保含带后缀的文件                
            foreach (FileSystemInfo f in dinfo.GetFileSystemInfos())
            {
                //目标路径destName = 目标文件夹路径 + 原文件夹下的子文件(或文件夹)名字                
                //Path.Combine(string a ,string b) 为合并两个字符串                     
                String destName = Path.Combine(dest, f.Name);
                if (f is FileInfo)//如果是文件就复制                     
                {
                    File.Copy(f.FullName, destName, true);//true代表可以覆盖同名文件                     
                }
                else//如果是文件夹就创建文件夹然后复制然后递归复制 
                {
                    Directory.CreateDirectory(destName);
                    CopyFile(f.FullName, destName);
                }
            }
        }

        /// <summary>
        /// 批量将文件移动到回收站
        /// </summary>
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public JsonResponse DatasToRestoreFile(string FILE_ID, string SpaceType)
        {
            JsonResponse response = new JsonResponse();
            response.success = false;
            //FILE_ID = FILE_ID.TrimEnd(',');
            FILE_ID = FILE_ID.Remove(FILE_ID.LastIndexOf(","), 1);
            try
            {
                //项目库
                if (SpaceType == "project")
                {
                    Tb_Xmk_FileBiz bll = new Tb_Xmk_FileBiz();
                    DataTable dt = bll.GetModelList(FILE_ID);
                    if (dt.Rows.Count > 0)
                    {
                        if (bll.RemoveToRecycle(FILE_ID))
                        {

                        }
                    }

                }
                //课题组
                else if (SpaceType == "group")
                {
                    TB_TEAM_FILEBiz Tbll = new TB_TEAM_FILEBiz();
                    DataTable tdt = Tbll.GetModelList(FILE_ID);
                    if (tdt.Rows.Count > 0)
                    {
                        if (Tbll.RemoveToRecycle(FILE_ID))
                        {

                        }
                    }
                }
                //个人
                else if (SpaceType == "individual")
                {
                    TB_PERSON_FILEBiz Pbll = new TB_PERSON_FILEBiz();
                    DataTable Pdt = Pbll.GetModelList(FILE_ID);
                    if (Pdt.Rows.Count > 0)
                    {
                        if (Pbll.RemoveToRecycle(FILE_ID))
                        {

                        }
                    }
                }
                response.success = true;
            }
            catch (Exception ex)
            {
                response.success = false;
            }
            return response;
        }

        /// <summary>
        /// 还原数据
        /// </summary>
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public JsonResponse RestoreDataFile(string FILE_ID, string SpaceType)
        {
            JsonResponse response = new JsonResponse();
            response.success = false;
            //FILE_ID = FILE_ID.TrimEnd(',');
            FILE_ID = FILE_ID.Remove(FILE_ID.LastIndexOf(","), 1);
            try
            {
                //项目库
                if (SpaceType == "project")
                {
                    Tb_Xmk_FileBiz bll = new Tb_Xmk_FileBiz();
                    DataTable dt = bll.GetModelList(FILE_ID);
                    if (dt.Rows.Count > 0)
                    {
                        if (bll.RecycleToSpace(FILE_ID))
                        {

                        }
                    }
                }
                //课题组
                if (SpaceType == "group")
                {
                    TB_TEAM_FILEBiz Tbll = new TB_TEAM_FILEBiz();
                    DataTable tdt = Tbll.GetModelList(FILE_ID);
                    if (tdt.Rows.Count > 0)
                    {
                        if (Tbll.RecycleToSpace(FILE_ID))
                        {

                        }
                    }
                }
                //个人
                if (SpaceType == "individual")
                {
                    TB_PERSON_FILEBiz Pbll = new TB_PERSON_FILEBiz();
                    DataTable Pdt = Pbll.GetModelList(FILE_ID);
                    if (Pdt.Rows.Count > 0)
                    {
                        if (Pbll.RecycleToSpace(FILE_ID))
                        {

                        }
                    }
                }
                response.success = true;
            }
            catch (Exception ex)
            {
                response.success = false;
            }
            return response;
        }

        /// <summary>
        /// 永久删除数据
        /// </summary>
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public JsonResponse DelDataFile(string FILE_ID, string SpaceType)
        {
            JsonResponse response = new JsonResponse();
            response.success = false;
            //FILE_ID = FILE_ID.TrimEnd(',');
            FILE_ID = FILE_ID.Remove(FILE_ID.LastIndexOf(","), 1);
            try
            {
                //项目库
                if (SpaceType == "project")
                {
                    Tb_Xmk_FileBiz bll = new Tb_Xmk_FileBiz();
                    DataTable dt = bll.GetModelList(FILE_ID);
                    if (dt.Rows.Count > 0)
                    {
                        if (bll.DeleteIN(FILE_ID))
                        {
                            if (dt.Rows.Count > 0)
                            {
                                for (int i = 0; i < dt.Rows.Count; i++)
                                {
                                    //获取存放路径
                                    string save_Path = ConfigurationManager.AppSettings["DiskPath"];
                                    //文档名称
                                    string SAVE_PATH = dt.Rows[i]["Save_Path"].ToString();
                                    string PDF_PATH = dt.Rows[i]["PDF_PATH"].ToString();
                                    string SWF_PATH = dt.Rows[i]["SWF_PATH"].ToString();
                                    //删除文件
                                    //1、删除源文件
                                    if (!string.IsNullOrEmpty(SAVE_PATH))
                                    {
                                        FileHelper.DeleteFile(save_Path + SAVE_PATH);
                                    }
                                    //2、删除PDF文件
                                    if (!string.IsNullOrEmpty(PDF_PATH))
                                    {
                                        FileHelper.DeleteFile(save_Path + PDF_PATH);
                                    }
                                    //3、删除swf文件
                                    if (!string.IsNullOrEmpty(SWF_PATH))
                                    {
                                        FileHelper.DeleteDirectory(save_Path + SWF_PATH, true);
                                    }

                                }
                            }
                        }
                    }
                }

                //课题组
                if (SpaceType == "group")
                {
                    TB_TEAM_FILEBiz Tbll = new TB_TEAM_FILEBiz();
                    DataTable tdt = Tbll.GetModelList(FILE_ID);
                    if (tdt.Rows.Count > 0)
                    {
                        if (Tbll.DeleteIN(FILE_ID))
                        {
                            if (tdt.Rows.Count > 0)
                            {
                                for (int i = 0; i < tdt.Rows.Count; i++)
                                {

                                    //获取存放路径
                                    string save_Path = ConfigurationManager.AppSettings["DiskPath"];
                                    //文档名称
                                    string SAVE_PATH = tdt.Rows[i]["Save_Path"].ToString();
                                    string PDF_PATH = tdt.Rows[i]["PDF_PATH"].ToString();
                                    string SWF_PATH = tdt.Rows[i]["SWF_PATH"].ToString();
                                    //删除文件
                                    //1、删除源文件
                                    if (!string.IsNullOrEmpty(SAVE_PATH))
                                    {
                                        FileHelper.DeleteFile(save_Path + SAVE_PATH);
                                    }
                                    //2、删除PDF文件
                                    if (!string.IsNullOrEmpty(PDF_PATH))
                                    {
                                        FileHelper.DeleteFile(save_Path + SAVE_PATH);
                                    }
                                    //3、删除swf文件
                                    if (!string.IsNullOrEmpty(SWF_PATH))
                                    {
                                        FileHelper.DeleteDirectory(save_Path + SWF_PATH, true);
                                    }


                                }
                            }
                        }
                    }
                }

                //个人
                if (SpaceType == "individual")
                {
                    TB_PERSON_FILEBiz Pbll = new TB_PERSON_FILEBiz();
                    DataTable Pdt = Pbll.GetModelList(FILE_ID);
                    if (Pdt.Rows.Count > 0)
                    {
                        if (Pbll.DeleteIN(FILE_ID))
                        {
                            if (Pdt.Rows.Count > 0)
                            {
                                for (int i = 0; i < Pdt.Rows.Count; i++)
                                {

                                    //获取存放路径
                                    string save_Path = ConfigurationManager.AppSettings["DiskPath"];
                                    //文档名称
                                    string SAVE_PATH = Pdt.Rows[i]["Save_Path"].ToString();
                                    string PDF_PATH = Pdt.Rows[i]["PDF_PATH"].ToString();
                                    string SWF_PATH = Pdt.Rows[i]["SWF_PATH"].ToString();
                                    //删除文件
                                    //1、删除源文件
                                    if (!string.IsNullOrEmpty(SAVE_PATH))
                                    {
                                        FileHelper.DeleteFile(save_Path + SAVE_PATH);
                                    }
                                    //2、删除PDF文件
                                    if (!string.IsNullOrEmpty(PDF_PATH))
                                    {
                                        FileHelper.DeleteFile(save_Path + PDF_PATH);
                                    }
                                    //3、删除swf文件
                                    if (!string.IsNullOrEmpty(SWF_PATH))
                                    {
                                        FileHelper.DeleteDirectory(save_Path + SWF_PATH, true);
                                    }

                                }
                            }
                        }
                    }
                }

                response.success = true;
            }
            catch (Exception ex)
            {
                response.success = false;
            }
            return response;
        }


        /// <summary>
        /// 课题组我的提交  GetTeamMySubmitData
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public List<MySubmitItem> GetTeamMySubmitData(string TeamID, string sorttype, string sortdesc, string status, int pageNum, int size)
        {
            Tb_Xmk_FileBiz bll = new Tb_Xmk_FileBiz();
            int startNum = (pageNum - 1) * size;
            int endNum = pageNum * size;//- objInfos.Count;
            int total = 0;
            DataTable dt = bll.GetUnauditedModelBySql(TeamID,sorttype,sortdesc, status, startNum, endNum + 1, ref total);
            List<MySubmitItem> items = new List<MySubmitItem>();
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                MySubmitItem item = new MySubmitItem();
                item.FILE_ID = dt.Rows[i]["FILE_ID"].ToString();
                item.FILE_NAME = dt.Rows[i]["FILE_NAME"].ToString();
                //item.STATSU = dt.Rows[i]["STATSU"].ToString();
                item.CREATE_TIME = dt.Rows[i]["CREATE_TIME"].ToString();
                item.TEAM_ID = TeamID;
                item.FileCount = total;
                item.Extension = item.FILE_NAME.Substring(item.FILE_NAME.LastIndexOf("."));
                items.Add(item);

            }
            return items;

        }

        /// <summary>
        /// 课题组未审核数据 
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public bool TeamAuditData(string ID)
        {
            TB_TEAM_FILEBiz bll = new TB_TEAM_FILEBiz();
            bool b = false;
            if (bll.AuditData(ID))
            {
                b = true;
            }
            return b;

        }

        /// <summary>
        /// 课题组批量未审核数据 
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public bool TeamAuditDatas(string ID)
        {
            TB_TEAM_FILEBiz bll = new TB_TEAM_FILEBiz();
            bool b = false;
            if (bll.AuditDatas(ID))
            {
                b = true;
            }
            return b;

        }


        /// <summary>
        /// 未审核数据  GetUnauditedData
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public List<shareFileItem> GetUnauditedData(string groupName, string sorttype, string sortdesc, int pageNum, int size)
        {
            TB_TEAM_FILEBiz bll = new TB_TEAM_FILEBiz();
            int startNum = (pageNum - 1) * size;
            int endNum = pageNum * size;
            int total = 0;
            DataTable dt = bll.getTeamFileInfoByTeamName(groupName,sorttype,sortdesc,startNum, endNum, ref total);
            //存放未审核数据列表
            List<shareFileItem> items = new List<shareFileItem>();
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                shareFileItem item = new shareFileItem();
                item.FILE_ID = dt.Rows[i]["FILE_ID"].ToString();
                item.FILE_NAME = dt.Rows[i]["FILE_NAME"].ToString();
                item.USER_ID = dt.Rows[i]["USER_ID"].ToString();
                item.USER_NAME = dt.Rows[i]["USER_NAME"].ToString();
                item.CREATE_TIME = dt.Rows[i]["CREATE_TIME"].ToString();
                item.UPD_TIME = dt.Rows[i]["UPD_TIME"].ToString();
                item.SAVE_PATH = dt.Rows[i]["SAVE_PATH"].ToString();
                item.TEAM_ID = dt.Rows[i]["TEAM_ID"].ToString();
                item.FileCount = total;
                item.Extension = item.FILE_NAME.Substring(item.FILE_NAME.LastIndexOf("."));
                items.Add(item);
            }
            return items;

        }

        /// <summary>
        /// 已审核数据  GetAuditedData
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public List<shareFileItem> GetAuditedData(string groupName, string sorttype, string sortdesc, int pageNum, int size)
        {
            TB_TEAM_FILEBiz bll = new TB_TEAM_FILEBiz();
            int startNum = (pageNum - 1) * size;
            int endNum = pageNum * size;
            int total = 0;
            DataTable dt = bll.getAuditedDataByTeamName(groupName, sorttype, sortdesc,startNum, endNum, ref total);
            //存放未审核数据列表
            List<shareFileItem> items = new List<shareFileItem>();
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                shareFileItem item = new shareFileItem();
                item.FILE_ID = dt.Rows[i]["FILE_ID"].ToString();
                item.FILE_NAME = dt.Rows[i]["FILE_NAME"].ToString();
                item.USER_NAME = dt.Rows[i]["USER_NAME"].ToString();
                item.CREATE_TIME = dt.Rows[i]["CREATE_TIME"].ToString();
                //item.UPD_TIME = dt.Rows[i]["UPD_TIME"].ToString();
                item.FileCount = total;
                item.Extension = item.FILE_NAME.Substring(item.FILE_NAME.LastIndexOf("."));
                items.Add(item);

            }
            return items;

        }


        /// <summary>
        /// 项目库未审核数据  GetProjectUnauditedData
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public List<shareFileItem> GetProjectUnauditedData(int pageNum, string sorttype, string sortdesc, int size)
        {
            Tb_Xmk_FileBiz bll = new Tb_Xmk_FileBiz();
            int startNum = (pageNum - 1) * size;
            int endNum = pageNum * size;
            int total = 0;
            DataTable dt = bll.GetXMKUnauditedModel(startNum,sorttype,sortdesc, endNum, ref total);
            //存放未审核数据列表
            List<shareFileItem> items = new List<shareFileItem>();
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                shareFileItem item = new shareFileItem();
                item.FILE_ID = dt.Rows[i]["FILE_ID"].ToString();
                item.FILE_NAME = dt.Rows[i]["FILE_NAME"].ToString();
                item.USER_ID = dt.Rows[i]["USER_ID"].ToString();
                item.USER_NAME = dt.Rows[i]["USER_NAME"].ToString();
                item.CREATE_TIME = dt.Rows[i]["CREATE_TIME"].ToString();
                item.UPD_TIME = dt.Rows[i]["UPD_TIME"].ToString();
                item.SAVE_PATH = dt.Rows[i]["SAVE_PATH"].ToString();
                item.FileCount = total;
                item.Extension = item.FILE_NAME.Substring(item.FILE_NAME.LastIndexOf("."));
                items.Add(item);
            }
            return items;

        }

        /// <summary>
        /// 项目库已审核数据 
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public List<shareFileItem> GetXMKAuditedData(int pageNum, string sorttype, string sortdesc, int size)
        {
            Tb_Xmk_FileBiz bll = new Tb_Xmk_FileBiz();
            int startNum = (pageNum - 1) * size;
            int endNum = pageNum * size;
            int total = 0;
            DataTable dt = bll.GetXMKAuditModel(startNum,sorttype,sortdesc, endNum, ref total);
            //存放未审核数据列表
            List<shareFileItem> items = new List<shareFileItem>();
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                shareFileItem item = new shareFileItem();
                item.FILE_ID = dt.Rows[i]["FILE_ID"].ToString();
                item.FILE_NAME = dt.Rows[i]["FILE_NAME"].ToString();
                item.USER_NAME = dt.Rows[i]["USER_NAME"].ToString();
                item.CREATE_TIME = dt.Rows[i]["CREATE_TIME"].ToString();
                item.UPD_TIME = dt.Rows[i]["UPD_TIME"].ToString();
                item.SAVE_PATH = dt.Rows[i]["SAVE_PATH"].ToString();
                item.FileCount = total;
                item.Extension = item.FILE_NAME.Substring(item.FILE_NAME.LastIndexOf("."));
                items.Add(item);

            }
            return items;

        }

        /// <summary>
        /// 个人空间是否有SWF文件
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public bool PerHasSWF1(string File_ID)
        {
            bool Flag = false;
            try
            {
                TB_PERSON_FILEInfo Pmodel = new TB_PERSON_FILEInfo();
                TB_PERSON_FILEBiz Pbll = new TB_PERSON_FILEBiz();
                Pmodel = Pbll.GetFileInfoById(File_ID);
                //判断文件格式是否为picture
                EXTBiz biz = new EXTBiz();
                ExtTypeinfo extcode = biz.getExtCodeByExtent(Pmodel.FILE_EXT);
                if (extcode == null)
                {
                    return true;
                }
                else if ((extcode.EXT_CODE != "word" && extcode.EXT_CODE != "excel" && extcode.EXT_CODE != "ppt" && extcode.EXT_CODE != "pdf" && extcode.EXT_CODE != "txt"))
                {
                    return true;
                }
              

                string DiskPath = ConfigurationManager.AppSettings["DiskPath"];
                string name = "";
                if (Pmodel == null)
                {
                    name = "";
                    Flag = false;
                }
                else
                {
                    name = Pmodel.SWF_PATH.ToString();

                }
                if (!string.IsNullOrEmpty(name))
                {
                    name = DiskPath + name + "1.swf";
                    if (File.Exists(name))
                    {
                        Flag = true;
                    }
                    else
                    {
                        Flag = false;
                    }
                }
            }
            catch (Exception ex)
            {
                Flag = false;
            }
            return Flag;
        }

        /// <summary>
        /// 个人空间是否有SWF文件
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public bool PerHasSWF(string RequestPath, string filename, string userId)
        {
            bool Flag = false;
            try
            {
                TB_PERSON_FILEInfo Pmodel = new TB_PERSON_FILEInfo();
                TB_PERSON_FILEBiz Pbll = new TB_PERSON_FILEBiz();
                Pmodel = Pbll.GetFileInfoById(RequestPath);
                //判断文件格式是否为picture
                EXTBiz biz = new EXTBiz();
                ExtTypeinfo extcode = biz.getExtCodeByExtent(Pmodel.FILE_EXT);
                if (extcode == null)
                {
                    return true;
                }
                else if ((extcode.EXT_CODE != "word" && extcode.EXT_CODE != "excel" && extcode.EXT_CODE != "ppt" && extcode.EXT_CODE != "pdf" && extcode.EXT_CODE != "txt"))
                {
                    return true;
                }
                string DiskPath = ConfigurationManager.AppSettings["DiskPath"];
                string name = "";
                if (Pmodel == null)
                {
                    name = "";
                    Flag = false;
                }
                else
                {
                    name = Pmodel.SWF_PATH.ToString();

                }
                if (!string.IsNullOrEmpty(name))
                {
                    name = DiskPath + name + "1.swf";
                    if (File.Exists(name))
                    {
                        Flag = true;
                    }
                    else
                    {
                        Flag = false;
                    }
                }
            }
            catch (Exception ex)
            {
                Flag = false;
            }
            return Flag;
        }

        /// <summary>
        /// 课题组空间是否有SWF文件
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public bool TeamHasSWF1(string File_ID)
        {
            bool Flag = false;
            try
            {
                //课题组
                TB_TEAM_FILEBiz Tbll = new TB_TEAM_FILEBiz();
                DataTable dt = Tbll.GetModel(File_ID);
                //判断文件格式是否为picture
                EXTBiz biz = new EXTBiz();
                ExtTypeinfo extcode = biz.getExtCodeByExtent(dt.Rows[0]["FILE_EXT"].ToString());
                if (extcode == null)
                {
                    return true;
                }
                else if ((extcode.EXT_CODE != "word" && extcode.EXT_CODE != "excel" && extcode.EXT_CODE != "ppt" && extcode.EXT_CODE != "pdf" && extcode.EXT_CODE != "txt"))
                {
                    return true;
                }
                string DiskPath = ConfigurationManager.AppSettings["DiskPath"];
                string name = "";
                if (dt.Rows.Count > 0)
                {
                    if (!string.IsNullOrEmpty(dt.Rows[0]["SWF_PATH"].ToString()))
                    {
                        name = dt.Rows[0]["SWF_PATH"].ToString();

                    }
                    else
                    {
                        Flag = false;
                    }
                    if (!string.IsNullOrEmpty(name))
                    {
                        name = DiskPath + name + "1.swf";
                        if (File.Exists(name))
                        {
                            Flag = true;
                        }
                        else
                        {
                            Flag = false;
                        }
                    }
                }
                else
                {
                    Flag = false;
                }

            }
            catch (Exception ex)
            {
                Flag = false;
            }
            return Flag;
        }

        /// <summary>
        /// 课题组空间是否有SWF文件
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public bool TeamHasSWF(string RequestPath, string filename, string teamid)
        {
            bool Flag = false;
            try
            {
                //课题组
                TB_TEAM_FILEBiz Tbll = new TB_TEAM_FILEBiz();
                DataTable dt = Tbll.GetModel(RequestPath);
                //判断文件格式是否为picture
                EXTBiz biz = new EXTBiz();
                ExtTypeinfo extcode = biz.getExtCodeByExtent(dt.Rows[0]["FILE_EXT"].ToString());
                if (extcode == null)
                {
                    return true;
                }
                else if ((extcode.EXT_CODE != "word" && extcode.EXT_CODE != "excel" && extcode.EXT_CODE != "ppt" && extcode.EXT_CODE != "pdf" && extcode.EXT_CODE != "txt"))
                {
                    return true;
                }
                string DiskPath = ConfigurationManager.AppSettings["DiskPath"];
                string name = "";
                if (dt.Rows.Count > 0)
                {
                    if (!string.IsNullOrEmpty(dt.Rows[0]["SWF_PATH"].ToString()))
                    {
                        name = dt.Rows[0]["SWF_PATH"].ToString();

                    }
                    else
                    {
                        Flag = false;
                    }
                    if (!string.IsNullOrEmpty(name))
                    {
                        name = DiskPath + name + "1.swf";
                        if (File.Exists(name))
                        {
                            Flag = true;
                        }
                        else
                        {
                            Flag = false;
                        }
                    }
                }
                else
                {
                    Flag = false;
                }

            }
            catch (Exception ex)
            {
                Flag = false;
            }
            return Flag;
        }


        /// <summary>
        /// 项目库空间是否有SWF文件
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public bool XMKHasSWF1(string File_ID)
        {
            bool Flag = false;
            try
            {
                //项目库
                Tb_Xmk_FileBiz Xbll = new Tb_Xmk_FileBiz();
                DataTable dt1 = Xbll.GetModel(File_ID);
                //判断文件格式是否为picture
                EXTBiz biz = new EXTBiz();
                ExtTypeinfo extcode = biz.getExtCodeByExtent(dt1.Rows[0]["FILE_EXT"].ToString());
                if (extcode == null)
                {
                    return true;
                }
                else if ((extcode.EXT_CODE != "word" && extcode.EXT_CODE != "excel" && extcode.EXT_CODE != "ppt" && extcode.EXT_CODE != "pdf" && extcode.EXT_CODE != "txt"))
                {
                    return true;
                }
                string DiskPath = ConfigurationManager.AppSettings["DiskPath"];
                string name = "";
                if (dt1.Rows.Count > 0)
                {
                    if (!string.IsNullOrEmpty(dt1.Rows[0]["SWF_PATH"].ToString()))
                    {
                        name = dt1.Rows[0]["SWF_PATH"].ToString();

                    }
                    else
                    {
                        Flag = false;
                    }
                    if (!string.IsNullOrEmpty(name))
                    {
                        name = DiskPath + name + "1.swf";
                        if (File.Exists(name))
                        {
                            Flag = true;
                        }
                        else
                        {
                            Flag = false;
                        }
                    }
                }

                else
                {
                    Flag = false;
                }

            }
            catch (Exception ex)
            {
                Flag = false;
            }
            return Flag;
        }


        /// <summary>
        /// 项目库空间是否有SWF文件
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public bool XMKHasSWF(string RequestPath, string filename)
        {
            bool Flag = false;
            try
            {
                //项目库
                Tb_Xmk_FileBiz Xbll = new Tb_Xmk_FileBiz();
                DataTable dt1 = Xbll.GetModel(RequestPath);
                //判断文件格式是否为picture
                EXTBiz biz = new EXTBiz();
                ExtTypeinfo extcode = biz.getExtCodeByExtent(dt1.Rows[0]["FILE_EXT"].ToString());
                if (extcode == null)
                {
                    return true;
                }
                else if ((extcode.EXT_CODE != "word" && extcode.EXT_CODE != "excel" && extcode.EXT_CODE != "ppt" && extcode.EXT_CODE != "pdf" && extcode.EXT_CODE != "txt"))
                {
                    return true;
                }
                string name = "";
                string DiskPath = ConfigurationManager.AppSettings["DiskPath"];
                if (dt1.Rows.Count > 0)
                {
                    if (!string.IsNullOrEmpty(dt1.Rows[0]["SWF_PATH"].ToString()))
                    {
                        name = dt1.Rows[0]["SWF_PATH"].ToString();

                    }
                    else
                    {
                        Flag = false;
                    }
                    if (!string.IsNullOrEmpty(name))
                    {
                        name = DiskPath + name + "1.swf";
                        if (File.Exists(name))
                        {
                            Flag = true;
                        }
                        else
                        {
                            Flag = false;
                        }
                    }
                }

                else
                {
                    Flag = false;
                }

            }
            catch (Exception ex)
            {
                Flag = false;
            }
            return Flag;
        }
        //public void insertSpaceLog(string fileIdList, string opraType)
        //{
        //    XMKLogInfo logModel = new XMKLogInfo();
        //    logModel.LogDesc = string.Format("【{0}】【{1}】删除了文件,{2}",
        //        LoginUserBiz.LoginUserName(), LoginUserBiz.LoginUserAccount(), logModel.Keyword);
        //    logModel.OperateTime = DateTime.Now;
        //    logModel.OperateType = LogOperateType.Search;
        //    logModel.UserId = LoginUserBiz.LoginUserID();
        //    logModel.IP = Request.ServerVariables["REMOTE_ADDR"].Equals("::1") ? "127.0.0.1" : Request.ServerVariables["REMOTE_ADDR"];
        //    XMKLogBiz.WriteLog(logModel);
        //}
        ///// <summary>
        /// 是否允许用户执行操作
        /// </summary>
        /// <param name="relativePath"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public bool Allowed(string relativePath, string type)
        {
            relativePath = relativePath.Trim();
            IEnumerable<ProtectedPath> protectedPaths;
            if (type == "r")
            {
                protectedPaths = config.ProtectedPaths.Where(p => p.RelativePath == relativePath && !p.AllowRead);
            }
            else if (type == "w")
            {
                protectedPaths = config.ProtectedPaths.Where(p => p.RelativePath == relativePath && !p.AllowWrite);
            }
            else // delete
            {
                protectedPaths = config.ProtectedPaths.Where(p => p.RelativePath == relativePath && !p.AllowDelete);
            }

            if (protectedPaths.Count() > 0)
            {
                foreach (ProtectedPath p in protectedPaths)
                {
                    foreach (string role in p.OverrideRoles)
                    {
                        if (User.IsInRole(role) || role == "Everyone")
                        {
                            return true;
                        }
                    }
                }
                return false;
            }
            else
            {
                return true;
            }
        }

        /// <summary>
        /// 获取文件夹
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public List<Folder> GetFolders(string path)
        {
            if (Session != null && Session["sub_path"] != null)
                config.SubPath = Session["sub_path"].ToString();

            path = path.Replace("~", config.FilesPath);
            string physicalPath = path;//Server.MapPath(path);
            return FileHelper.GetFolderList(physicalPath, GetBasePath());
        }

        /// <summary>
        /// 获取文件集
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public List<FolderFile> GetFiles(string path)
        {
            if (Session != null && Session["sub_path"] != null)
                config.SubPath = Session["sub_path"].ToString();

            path = path.Replace("~", config.FilesPath);
            string physicalPath = path;// Server.MapPath(path);
            return FileHelper.GetFileList(physicalPath, GetBasePath());
        }


        #region Operation

        /// <summary>
        /// 删除文件，或者文件夹
        /// </summary>
        /// <param name="paths"></param>
        /// <param name="recursive"></param>
        /// <returns></returns>
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public JsonResponse Delete(string paths, bool recursive = false)
        {
            string userId = Context.Request.Cookies["user_id"].Value;
            if (Session != null && Session["sub_path"] != null)
                config.SubPath = Session["sub_path"].ToString();

            string filteredPaths = "";
            foreach (string p in paths.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries))
            {
                ///string fp = p.Replace("~/", config.BasePath);
                if (Allowed(p, "x"))
                {
                    filteredPaths += p + ",";
                }
            }
            if (string.IsNullOrEmpty(filteredPaths))
            {
                JsonResponse response = new JsonResponse();
                response.success = false;
                response.message = lang_server.Get("Cannot delete these files or folders");
                return response;
            }
            else
            {
                //string strPath_Name = 
                TB_PERSON_FILEBiz fileBiz = new TB_PERSON_FILEBiz();

                string[] files = paths.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                if (files.Count() > 0)
                {
                    foreach (string f in files)
                    {
                        //删除目标树里的节点
                        if (Directory.Exists(f))
                        {
                            DirectoryInfo dirInfo = new DirectoryInfo(f);

                            if (dirInfo.GetFiles().Count() > 0 || dirInfo.GetDirectories().Count() > 0)
                            {
                                JsonResponse response = new JsonResponse();
                                response.success = false;
                                response.message = lang_server.Get("The directory is not empty, can not be deleted");
                                return response;
                            }
                            TB_Tree_ObjectBiz objTree = new TB_Tree_ObjectBiz();
                            string mainPath = config.FilesPath;
                            objTree.Delete(mainPath, f);
                        }
                        else if (File.Exists(f))
                        {
                            FileInfo fileInfo = new FileInfo(f);
                            string path = fileInfo.DirectoryName + "/";
                            path = path.Replace('\\', '/');
                            string tmp = path.Substring(path.IndexOf(config.SubPath));
                            tmp = tmp.EndsWith("/") ? tmp.Substring(0, tmp.Length - 1) : tmp;

                            fileBiz.DeleteBy_PathAndName(tmp, fileInfo.Name, userId);
                        }
                    }
                }

                //fileBiz.DeleteBy_PathAndName(
                filteredPaths = filteredPaths.Replace("~/", GetBasePath());
                return FileHelper.DeleteFiles(filteredPaths, recursive);
            }
        }


        #region Operate about project

        //项目库新建文件夹
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public JsonResponse ProjectNewFolder(string path, string name)
        {
            if (Session != null && Session["sub_path"] != null)
                config.SubPath = Session["sub_path"].ToString();
            path = path.Replace("~/", "0");
            if (Allowed(path, "w"))
            {
                string destPath = path;//Server.MapPath(path);
                TB_Tree_ObjectBiz objTree = new TB_Tree_ObjectBiz();
                string mainPath = "";
                bool result = objTree.AddDir(mainPath, path, name);

                JsonResponse response = new JsonResponse();
                response.success = result;
                response.data = path;
                if (result)
                {
                    response.message = string.Format(lang_server.Get("Folder") + "[{0}]" + lang_server.Get("Successfully created"), name);
                }
                else
                {
                    response.message = string.Format(lang_server.Get("Folder") + "[{0}]" + lang_server.Get("Creation failed"), name);
                }

                return response;
            }
            else
            {
                JsonResponse response = new JsonResponse();
                response.success = false;
                response.message = string.Format(lang_server.Get("The folder 0 to be protected, you cannot add a folder to the"), path);
                return response;
            }
        }






        //项目库文件删除
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public JsonResponse ProjectDelete(string paths, bool recursive = false)
        {
            JsonResponse response = new JsonResponse();
            response.success = true;

            string fileId = paths;
            try
            {
                Tb_Xmk_FileBiz fileBiz = new Tb_Xmk_FileBiz();
                DataTable dt = fileBiz.GetModel(fileId);
                DataRow dr = dt.Rows[0];
                string dest_obj = Convert.ToString(dr["FOLDER_ID"]);
                response.data = dest_obj;

                string save_path = Convert.ToString(dr["SAVE_PATH"]);
                string file_name = Convert.ToString(dr["FILE_NAME"]);

                bool isMoreThanOne = fileBiz.isMoreThanOne(save_path, file_name);
                if (!isMoreThanOne)
                {
                    if (!fileBiz.HasSavePath(save_path))
                    {
                        if (dr["SAVE_PATH"] != null && dr["FILE_NAME"] != null)
                        {

                            string fileName = ConfigurationManager.AppSettings["DiskPath"] + dr["SAVE_PATH"].ToString() + "/" + dr["FILE_NAME"].ToString();
                            if (File.Exists(fileName))
                            {
                                File.Delete(fileName);
                            }
                        }

                        if (dr["PDF_PATH"] != null)
                        {
                            string pdfPathName = ConfigurationManager.AppSettings["DiskPath"] + dr["PDF_PATH"].ToString();
                            if (File.Exists(pdfPathName))
                            {
                                File.Delete(pdfPathName);
                            }

                        }

                        if (dr["SWF_PATH"] != null)
                        {
                            string swfPathName = ConfigurationManager.AppSettings["DiskPath"] + dr["SWF_PATH"].ToString();
                            if (File.Exists(swfPathName))
                            {
                                File.Delete(swfPathName);
                            }
                        }
                    }
                }
                fileBiz.Delete(Convert.ToDecimal(fileId));


                response.message = lang_server.Get("Files deleted successfully");
            }
            catch (Exception ex)
            {
                response.message = ex.Message;
            }

            return response;
        }


        //项目库文件移动到回收站
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public JsonResponse ProjectRemoveToRecycle(string paths, bool recursive = false)
        {
            JsonResponse response = new JsonResponse();
            response.success = true;

            string fileId = paths;
            try
            {
                Tb_Xmk_FileBiz fileBiz = new Tb_Xmk_FileBiz();
                DataTable dt = fileBiz.GetModel(fileId);
                DataRow dr = dt.Rows[0];
                string dest_obj = Convert.ToString(dr["FOLDER_ID"]);
                response.data = dest_obj;

                fileBiz.RemoveToRecycle(fileId);


                response.message = lang_server.Get("Files deleted successfully");
            }
            catch (Exception ex)
            {
                response.message = ex.Message;
            }

            return response;
        }


        //项目库文件夹删除
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public JsonResponse ProjectDeleteWJJ(string paths, bool recursive = false)
        {
            JsonResponse response = new JsonResponse();
            response.success = true;

            string fileId = paths;
            try
            {
                Tb_Xmk_FileBiz fileBiz = new Tb_Xmk_FileBiz();
                DataTable dt = fileBiz.getXmkFileByFOLDER_ID(fileId);
                // string dest_obj = Convert.ToString(dr["FOLDER_ID"]);
                DataTable dt2 = fileBiz.GetSTree_XmkBySql(fileId);

                if (dt.Rows.Count > 0 || dt2.Rows.Count > 0)
                {
                    response.message = lang_server.Get("The folder cannot be deleted");
                    response.data = fileId;
                }
                else
                {
                    response.data = fileId;

                    if (fileBiz.deleteTREE_XMK(fileId))
                    {
                        response.message = lang_server.Get("The folder is deleted successfully");
                    }
                    else
                    {
                        response.message = lang_server.Get("Failed to delete the folder");
                    }
                }
            }
            catch (Exception ex)
            {
                response.message = ex.Message;
            }

            return response;
        }


        //项目库文件批量审核
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public JsonResponse ProjectCutDatas(string paths, string newPath)
        {
            JsonResponse response = new JsonResponse();
            response.success = true;
            newPath = newPath.Replace("~/", "");
            string fileId = paths;
            try
            {
                Tb_Xmk_FileBiz fileBiz = new Tb_Xmk_FileBiz();

                fileBiz.UpdateDatas(paths, newPath);

                response.message = lang_server.Get("move succeeded");
            }
            catch (Exception ex)
            {
                response.success = false;
                response.message = ex.Message;
            }

            return response;
        }


        //项目库文件移动
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public JsonResponse ProjectCut(string paths, string newPath)
        {
            JsonResponse response = new JsonResponse();
            response.success = true;
            newPath = newPath.Replace("~/", "");
            string fileId = paths;
            try
            {
                Tb_Xmk_FileBiz fileBiz = new Tb_Xmk_FileBiz();
                TB_XMK_FILEInfo fileInfo = fileBiz.QueryById(fileId);
                response.data = fileInfo.FOLDER_ID;// fileInfo.DEST_OBJ;

                fileInfo.FOLDER_ID = Convert.ToUInt32(newPath);
                fileBiz.Update(fileInfo);

                response.message = lang_server.Get("move succeeded");
            }
            catch (Exception ex)
            {
                response.success = false;
                response.message = ex.Message;
            }

            return response;
        }


        //项目库文件夹移动
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public JsonResponse ProjectCutWJJ(string paths, string newPath)
        {
            JsonResponse response = new JsonResponse();
            response.success = true;
            newPath = newPath.Replace("~/", "");
            string fileId = paths;
            try
            {
                Tb_Xmk_FileBiz fileBiz = new Tb_Xmk_FileBiz();

                TB_Tree_ObjectInfo fileInfo = new TB_Tree_ObjectInfo();
                DataTable dt = fileBiz.GetTree_Xmk(fileId);
                if (dt.Rows.Count > 0)
                {
                    response.data = fileInfo.ObjectID;// fileInfo.DEST_OBJ;

                    fileInfo.ObjectID = Convert.ToInt32(paths);
                    fileInfo.PObjectID = Convert.ToInt32(newPath);
                    fileBiz.UpdateTree_XmkCUT(fileInfo);

                    response.message = lang_server.Get("move succeeded");
                }
                else
                {
                    response.message = lang_server.Get("Failed to move");
                }
            }
            catch (Exception ex)
            {
                response.success = false;
                response.message = ex.Message;
            }

            return response;
        }

        //项目库文件复制
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public JsonResponse ProjectCopy(string paths, string newPath)
        {
            JsonResponse response = new JsonResponse();
            response.success = true;
            newPath = newPath.Replace("~/", "");
            string fileId = paths;
            try
            {
                Tb_Xmk_FileBiz fileBiz = new Tb_Xmk_FileBiz();
                TB_XMK_FILEInfo fileInfo = fileBiz.QueryById(fileId);
                response.data = fileInfo.FOLDER_ID;

                fileInfo.FOLDER_ID = Convert.ToUInt32(newPath);
                fileBiz.Upload(fileInfo);
                //fileBiz.Update(fileInfo);

                response.message = lang_server.Get("Copy success");
            }
            catch (Exception ex)
            {
                response.success = false;
                response.message = ex.Message;
            }

            return response;
        }

        //项目库文件夹复制
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public JsonResponse ProjectCopyWJJ(string paths, string newPath)
        {
            JsonResponse response = new JsonResponse();
            response.success = true;
            newPath = newPath.Replace("~/", "");
            string fileId = paths;
            try
            {
                Tb_Xmk_FileBiz fileBiz = new Tb_Xmk_FileBiz();
                TB_XMK_FILEInfo fileInfo = fileBiz.QueryById(fileId);
                response.data = fileInfo.FOLDER_ID;

                fileInfo.FOLDER_ID = Convert.ToUInt32(newPath);
                fileBiz.Upload(fileInfo);
                //fileBiz.Update(fileInfo);

                response.message = lang_server.Get("Copy success");
            }
            catch (Exception ex)
            {
                response.success = false;
                response.message = ex.Message;
            }

            return response;
        }

        //项目库文件重命名
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public JsonResponse ProjectRename(string path, string newName)
        {
            JsonResponse response = new JsonResponse();
            response.success = true;
            string fileId = path;
            try
            {
                Tb_Xmk_FileBiz fileBiz = new Tb_Xmk_FileBiz();
                TB_XMK_FILEInfo fileInfo = fileBiz.QueryById(fileId);
                fileInfo.FILE_NAME = newName;
                response.data = fileInfo.FOLDER_ID;
                fileBiz.Update(fileInfo);
                response.message = lang_server.Get("Rename success");
            }
            catch (Exception ex)
            {
                response.success = false;
                response.message = ex.Message;
            }

            return response;
        }


        /// <summary>
        /// 项目库文件夹重命名
        /// </summary>
        /// <param name="path"></param>
        /// <param name="newName"></param>
        /// <returns></returns>
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public JsonResponse ProjectRenameWJJ(string path, string newName)
        {
            JsonResponse response = new JsonResponse();
            response.success = true;
            string fileId = path;
            try
            {
                Tb_Xmk_FileBiz fileBiz = new Tb_Xmk_FileBiz();

                TB_Tree_ObjectInfo fileInfo = new TB_Tree_ObjectInfo();
                DataTable dt = fileBiz.GetTree_Xmk(fileId);
                if (dt.Rows.Count > 0)
                {
                    fileInfo.ObjectName = newName;
                    fileInfo.ObjectID = int.Parse(dt.Rows[0]["OBJ_ID"].ToString());
                    response.data = dt.Rows[0]["OBJ_ID"];
                    fileBiz.UpdateTree_Xmk(fileInfo);
                    response.message = lang_server.Get("Rename success");
                }
                else
                {
                    response.message = lang_server.Get("Rename failed");
                }

            }
            catch (Exception ex)
            {
                response.success = false;
                response.message = ex.Message;
            }

            return response;
        }



        /// <summary>
        /// 项目库审核文件
        /// </summary>
        /// <param name="paths"></param>
        /// <param name="recursive"></param>
        /// <returns></returns>
        //[WebMethod(EnableSession = true)]
        //[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        //public bool XMKAuditData(string id)
        //{
        //    Tb_Xmk_FileBiz bll = new Tb_Xmk_FileBiz();
        //     JsonResponse response = new JsonResponse();
        //     return bll.AuditData(id);
        //     //{
        //     //    response.success = true;
        //     //}
        //     //else
        //     //{
        //     //    response.success = true;
        //     //}

        //     //return response;

        //}


        /// <summary>
        /// 项目库未审核数据  GetProjectUnauditedData
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public bool XMKAuditData(string ID)
        {
            Tb_Xmk_FileBiz bll = new Tb_Xmk_FileBiz();
            bool b = false;
            if (bll.AuditData(ID))
            {
                b = true;
            }
            return b;

        }


        #endregion  Project



        #region Operate about group

        /// <summary>
        /// 删除文件，或者文件夹 课题组模式
        /// </summary>
        /// <param name="paths"></param>
        /// <param name="recursive"></param>
        /// <returns></returns>
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public JsonResponse GroupDelete(string paths, bool recursive = false)
        {
            string teamId = Context.Request.Cookies["team_id"].Value;
            if (Session != null && Session["sub_path"] != null)
                config.SubPath = Session["sub_path"].ToString();

            string filteredPaths = "";
            foreach (string p in paths.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries))
            {
                ///string fp = p.Replace("~/", config.BasePath);
                if (Allowed(p, "x"))
                {
                    filteredPaths += p + ",";
                }
            }
            if (string.IsNullOrEmpty(filteredPaths))
            {
                JsonResponse response = new JsonResponse();
                response.success = false;
                response.message = lang_server.Get("Cannot delete these files or folders");
                return response;
            }
            else
            {
                //string strPath_Name = 

                TB_TEAM_FILEBiz fileBiz = new TB_TEAM_FILEBiz();
                string[] files = paths.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                if (files.Count() > 0)
                {
                    foreach (string f in files)
                    {
                        if (File.Exists(f))
                        {
                            FileInfo fileInfo = new FileInfo(f);
                            string path = fileInfo.DirectoryName + "/";
                            path = path.Replace('\\', '/');
                            int file_id = fileBiz.GetIdByPathName(teamId, path.Substring(path.IndexOf(config.SubPath)), fileInfo.Name.Trim());
                            fileBiz.Delete(file_id.ToString());
                            // fileBiz.DeleteBy_PathAndName(path.Substring(path.IndexOf(config.SubPath)), fileInfo.Name);
                        }
                    }
                }

                //fileBiz.DeleteBy_PathAndName(
                filteredPaths = filteredPaths.Replace("~/", GetBasePath());
                return FileHelper.DeleteFiles(filteredPaths, recursive);
            }
        }


        /// <summary>
        /// 重命名文件，或者文件夹
        /// </summary>
        /// <param name="path"></param>
        /// <param name="newName"></param>
        /// <returns></returns>
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public JsonResponse GroupRename(string path, string newName)
        {
            string team_id = Context.Request.Cookies["team_id"].Value;
            if (Session != null && Session["sub_path"] != null)
                config.SubPath = Session["sub_path"].ToString();

            path = path.Replace("~/", config.FilesPath);//("~", config.BasePath);
            if (Allowed(path, "w"))
            {
                // DirectoryInfo dirInfo = new DirectoryInfo(path);
                if (Directory.Exists(path))
                {

                    DirectoryInfo dirInfo = new DirectoryInfo(path);
                    if (dirInfo.GetFiles().Count() > 0 || dirInfo.GetDirectories().Count() > 0)
                    {
                        JsonResponse response = new JsonResponse();
                        response.success = false;
                        response.message = lang_server.Get("The directory is not empty, can not be deleted");
                        return response;
                    }

                    TB_Tree_ObjectBiz objTree = new TB_Tree_ObjectBiz();
                    string mainPath = config.FilesPath;
                    objTree.Rename(mainPath, path, newName);
                }
                else
                {
                    string modelPath = path.Substring(path.IndexOf(config.SubPath));
                    string modelName = modelPath.Substring(modelPath.LastIndexOf('/') + 1);
                    modelPath = modelPath.Replace('/' + modelName, "");
                    TB_TEAM_FILEBiz fileBiz = new TB_TEAM_FILEBiz();
                    TB_TEAM_FILEInfo fileInfo = fileBiz.Query(team_id, modelName, modelPath);
                    //TB_PERSON_FILEBiz fileBiz = new TB_PERSON_FILEBiz();

                    //  TB_PERSON_FILEInfo fileObj = fileBiz.GetFileInfoBy_PathAndName(modelPath, modelName,userId);
                    fileInfo.FILE_NAME = newName;
                    fileInfo.UPD_TIME = DateTime.Now;
                    fileBiz.Update(fileInfo);

                }
                return FileHelper.Rename(path, newName);
            }
            else
            {
                JsonResponse response = new JsonResponse();
                response.success = false;
                response.message = lang_server.Get("Cannot modify these files or folders");
                return response;
            }
        }
        /// <summary>
        /// 剪切
        /// </summary>
        /// <param name="paths"></param>
        /// <param name="newPath"></param>
        /// <returns></returns>
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public bool GroupCut(string paths, string newPath)
        {
            string FOLDER_ID = newPath;
            string File_ID = paths;
            TB_TEAM_FILEBiz fileBiz = new TB_TEAM_FILEBiz();
            TB_TEAM_FILEInfo fileObj = fileBiz.GetTeamFile(File_ID);
            fileObj.UPD_TIME = DateTime.Now;

            fileObj.STATUS = 1;
            FOLDER_ID = FOLDER_ID.Replace("~/", "");
            fileObj.FOLDER_ID = FOLDER_ID;

            return fileBiz.Update(fileObj);
        }

        /// <summary>
        /// 批量审核课题组数据
        /// </summary>
        /// <param name="paths"></param>
        /// <param name="newPath"></param>
        /// <returns></returns>
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public bool GroupCutDatas(string paths, string newPath)
        {
            string FOLDER_ID = newPath;
            string File_ID = paths;
            TB_TEAM_FILEBiz fileBiz = new TB_TEAM_FILEBiz();
            string UPD_TIME = DateTime.Now.ToString();
            FOLDER_ID = FOLDER_ID.Replace("~/", "");
            return fileBiz.UpdateDatas(File_ID, FOLDER_ID, UPD_TIME);
        }




        /// <summary>
        /// 复制
        /// </summary>
        /// <param name="paths"></param>
        /// <param name="newPath"></param>
        /// <returns></returns>
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public JsonResponse GroupCopy(string paths, string newPath)
        {

            string teamId = Context.Request.Cookies["team_id"].Value;
            if (Session != null && Session["sub_path"] != null)
                config.SubPath = Session["sub_path"].ToString();
            paths = paths.Replace("~/", GetBasePath());
            newPath = newPath.Replace("~/", config.FilesPath);
            TB_TEAM_FILEBiz fileBiz = new TB_TEAM_FILEBiz();
            //TB_PERSON_FILEBiz fileBiz = new TB_PERSON_FILEBiz();
            string modelPath = paths.Substring(paths.IndexOf(config.SubPath));
            string newModelPath = newPath.Substring(newPath.IndexOf(config.SubPath));
            if (newModelPath.EndsWith("/"))
            {
                newModelPath = newModelPath.Substring(0, newModelPath.Length - 1);
            }
            string modelName = modelPath.Substring(modelPath.LastIndexOf('/') + 1);
            modelPath = modelPath.Replace('/' + modelName, "");
            TB_TEAM_FILEInfo fileObj = fileBiz.Query(teamId, modelName, modelPath);
            fileObj.SAVE_PATH = newModelPath;
            fileObj.UPD_TIME = DateTime.Now;
            if (!String.IsNullOrEmpty(fileObj.PDF_PATH))
            {
                string pdfPathName = ConfigurationManager.AppSettings["DiskPath"] + fileObj.PDF_PATH;
                string pdfFileName = fileObj.PDF_PATH;
                pdfFileName = pdfFileName.Substring(pdfFileName.LastIndexOf('/') + 1);
                fileObj.PDF_PATH = newModelPath + "/" + pdfFileName;
                File.Copy(pdfPathName, ConfigurationManager.AppSettings["DiskPath"] + fileObj.PDF_PATH);
            }
            if (!String.IsNullOrEmpty(fileObj.SWF_PATH))
            {
                string swfPathName = ConfigurationManager.AppSettings["DiskPath"] + fileObj.SWF_PATH;
                string swfFileName = fileObj.SWF_PATH;
                swfFileName = swfFileName.Substring(swfFileName.LastIndexOf('/') + 1);
                fileObj.SWF_PATH = newModelPath + "/" + swfFileName;
                File.Copy(swfPathName, ConfigurationManager.AppSettings["DiskPath"] + fileObj.SWF_PATH);

            }
            fileBiz.Add(fileObj);

            //newPath = Server.MapPath(newPath);
            return FileHelper.Copy(paths, newPath);
        }


        #region 关于课题组文件夹操作

        //课题组空间新建文件夹
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public JsonResponse TeamNewFolder(string path, string name, string team_id)
        {
            string userId = Context.Request.Cookies["user_id"].Value;

            if (Session != null && Session["sub_path"] != null)
                config.SubPath = Session["sub_path"].ToString();
            path = path.Replace("~/", "0");
            if (Allowed(path, "w"))
            {
                string destPath = path;//Server.MapPath(path);
                TB_Tree_ObjectBiz objTree = new TB_Tree_ObjectBiz();
                string mainPath = "";
                bool result = objTree.TeamAddDir(mainPath, path, name, userId, team_id);

                JsonResponse response = new JsonResponse();
                response.success = result;
                response.data = path;
                if (result)
                {
                    response.message = string.Format(lang_server.Get("Folder") + "[{0}]" + lang_server.Get("Successfully created"), name);
                }
                else
                {
                    response.message = string.Format(lang_server.Get("Folder") + "[{0}]" + lang_server.Get("Creation failed"), name);
                }

                return response;
            }
            else
            {
                JsonResponse response = new JsonResponse();
                response.success = false;
                response.message = string.Format(lang_server.Get("The folder 0 to be protected, you cannot add a folder to the"), path);
                return response;
            }
        }


        /// <summary>
        /// 课题组文件夹重命名
        /// </summary>
        /// <param name="path"></param>
        /// <param name="newName"></param>
        /// <returns></returns>
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public JsonResponse TeamRenameWJJ(string path, string newName)
        {
            JsonResponse response = new JsonResponse();
            response.success = true;
            string fileId = path;
            try
            {
                TB_Tree_ObjectBiz fileBiz = new TB_Tree_ObjectBiz();

                TB_Tree_ObjectInfo fileInfo = new TB_Tree_ObjectInfo();
                DataTable dt = fileBiz.GetTree_Team(fileId);
                if (dt.Rows.Count > 0)
                {
                    fileInfo.ObjectName = newName;
                    fileInfo.ObjectID = int.Parse(dt.Rows[0]["OBJ_ID"].ToString());
                    response.data = dt.Rows[0]["OBJ_ID"];
                    fileBiz.TeamRename(fileInfo);
                    response.message = lang_server.Get("Rename success");
                }
                else
                {
                    response.message = lang_server.Get("Rename failed");
                }

            }
            catch (Exception ex)
            {
                response.success = false;
                response.message = ex.Message;
            }

            return response;
        }

        //课题组空间文件重命名
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public JsonResponse TeamRenameWJ(string path, string newName)
        {
            JsonResponse response = new JsonResponse();
            response.success = true;
            string fileId = path;
            try
            {
                TB_TEAM_FILEBiz fileBiz = new TB_TEAM_FILEBiz();
                TB_TEAM_FILEInfo fileInfo = fileBiz.GetTeamFile(fileId);
                fileInfo.FILE_NAME = newName;
                response.data = fileInfo.FOLDER_ID;
                fileBiz.Update(fileInfo);
                response.message = lang_server.Get("Rename success");
            }
            catch (Exception ex)
            {
                response.success = false;
                response.message = ex.Message;
            }

            return response;
        }

        //课题组空间文件夹移动
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public JsonResponse TeamCutWJJ(string paths, string newPath)
        {
            JsonResponse response = new JsonResponse();
            response.success = true;
            newPath = newPath.Replace("~/", "");
            string fileId = paths;
            try
            {
                TB_Tree_ObjectBiz fileBiz = new TB_Tree_ObjectBiz();

                TB_Tree_ObjectInfo fileInfo = new TB_Tree_ObjectInfo();
                DataTable dt = fileBiz.GetTree_Team(fileId);
                if (dt.Rows.Count > 0)
                {
                    response.data = fileInfo.ObjectID;// fileInfo.DEST_OBJ;

                    fileInfo.ObjectID = Convert.ToInt32(paths);
                    fileInfo.PObjectID = Convert.ToInt32(newPath);
                    fileBiz.UpdateTree_TeamCUT(fileInfo);

                    response.message = lang_server.Get("move succeeded");
                }
                else
                {
                    response.message = lang_server.Get("Failed to move");
                }
            }
            catch (Exception ex)
            {
                response.success = false;
                response.message = ex.Message;
            }

            return response;
        }

        //课题组空间文件移动
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public JsonResponse TeamCutWJ(string paths, string newPath)
        {
            JsonResponse response = new JsonResponse();
            response.success = true;
            newPath = newPath.Replace("~/", "");
            string fileId = paths;
            try
            {
                TB_TEAM_FILEBiz fileBiz = new TB_TEAM_FILEBiz();
                TB_TEAM_FILEInfo fileInfo = fileBiz.GetTeamFile(fileId);
                response.data = fileInfo.FOLDER_ID;// fileInfo.DEST_OBJ;

                fileInfo.FOLDER_ID = newPath;
                fileBiz.Update(fileInfo);

                response.message = lang_server.Get("move succeeded");
            }
            catch (Exception ex)
            {
                response.success = false;
                response.message = ex.Message;
            }

            return response;
        }

        //课题组空间文件复制
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public JsonResponse TeamCopyWJ(string paths, string newPath)
        {
            JsonResponse response = new JsonResponse();
            response.success = true;
            newPath = newPath.Replace("~/", "");
            string fileId = paths;
            try
            {
                TB_TEAM_FILEBiz fileBiz = new TB_TEAM_FILEBiz();
                TB_TEAM_FILEInfo fileInfo = fileBiz.GetTeamFile(fileId);
                response.data = fileInfo.FOLDER_ID;

                fileInfo.FOLDER_ID = newPath;
                fileBiz.CopyFile(fileInfo);

                response.message = lang_server.Get("Copy success");
            }
            catch (Exception ex)
            {
                response.success = false;
                response.message = ex.Message;
            }

            return response;
        }

        //课题组空间文件夹删除
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public JsonResponse TeamDeleteWJJ(string paths, bool recursive = false)
        {
            JsonResponse response = new JsonResponse();
            response.success = true;

            string fileId = paths;
            try
            {
                TB_PERSON_FILEBiz fileBiz = new TB_PERSON_FILEBiz();

                DataTable dt = fileBiz.GeTeamFile(fileId);
                // string dest_obj = Convert.ToString(dr["FOLDER_ID"]);
                TB_Tree_ObjectBiz fileBiz1 = new TB_Tree_ObjectBiz();
                DataTable dt2 = fileBiz1.GetTree_TeamP_ID(fileId);

                if (dt.Rows.Count > 0 || dt2.Rows.Count > 0)
                {
                    response.message = lang_server.Get("The folder cannot be deleted");
                    response.data = fileId;
                }
                else
                {
                    response.data = fileId;

                    if (fileBiz1.deleteTREE_TeamBySQL(fileId))
                    {
                        response.message = lang_server.Get("The folder is deleted successfully");
                    }
                    else
                    {
                        response.message = lang_server.Get("Failed to delete the folder");
                    }
                }
            }
            catch (Exception ex)
            {
                response.message = ex.Message;
            }

            return response;
        }

        //课题组空间文件删除
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public JsonResponse TeamDeleteWJ(string paths, bool recursive = false)
        {
            JsonResponse response = new JsonResponse();
            response.success = true;

            string fileId = paths;
            try
            {
                TB_TEAM_FILEBiz fileBiz = new TB_TEAM_FILEBiz();
                TB_TEAM_FILEInfo dt = fileBiz.GetTeamFile(fileId);
                //DataRow dr = dt.Rows[0];
                string dest_obj = dt.FOLDER_ID;


                response.data = dest_obj;

                string save_path = dt.SAVE_PATH;
                string file_name = dt.FILE_NAME;

                bool isMoreThanOne = fileBiz.IsMoreThanOne(paths);
                if (!isMoreThanOne)
                {
                    if (!fileBiz.HasSavePath(save_path))
                    {
                        //删除源文件
                        if (!string.IsNullOrEmpty(dt.SAVE_PATH))
                        {

                            string fileName = ConfigurationManager.AppSettings["DiskPath"] + dt.SAVE_PATH.ToString();
                            if (File.Exists(fileName))
                            {
                                File.Delete(fileName);
                            }
                        }
                        //删除pdf文件
                        if (!string.IsNullOrEmpty(dt.PDF_PATH))
                        {
                            string pdfPathName = ConfigurationManager.AppSettings["DiskPath"] + dt.PDF_PATH.ToString();
                            if (File.Exists(pdfPathName))
                            {
                                File.Delete(pdfPathName);
                            }

                        }
                        //删除swf文件
                        if (!string.IsNullOrEmpty(dt.SWF_PATH))
                        {
                            string swfPathName = ConfigurationManager.AppSettings["DiskPath"] + dt.SWF_PATH.ToString();
                            if (File.Exists(swfPathName))
                            {
                                File.Delete(swfPathName);
                            }
                        }
                    }
                }
                fileBiz.Delete(fileId);


                response.message = lang_server.Get("Files deleted successfully");
            }
            catch (Exception ex)
            {
                response.message = ex.Message;
            }

            return response;
        }


        //课题组空间文件移动到回收站
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public JsonResponse TeamRemoveToRecycleWJ(string paths, bool recursive = false)
        {
            JsonResponse response = new JsonResponse();
            response.success = true;

            string fileId = paths;
            try
            {
                TB_TEAM_FILEBiz fileBiz = new TB_TEAM_FILEBiz();
                TB_TEAM_FILEInfo dt = fileBiz.GetTeamFile(fileId);
                //DataRow dr = dt.Rows[0];
                string dest_obj = dt.FOLDER_ID;


                response.data = dest_obj;


                fileBiz.RemoveToRecycle(fileId);


                response.message = lang_server.Get("Failed to delete the file");
            }
            catch (Exception ex)
            {
                response.message = ex.Message;
            }

            return response;
        }

        #endregion 关于课题组文件夹操作




        #endregion   group operate


        #region Operate about Individual

        //个人空间新建文件夹
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public JsonResponse PersonNewFolder(string path, string name)
        {
            string userId = Context.Request.Cookies["user_id"].Value;
            if (Session != null && Session["sub_path"] != null)
                config.SubPath = Session["sub_path"].ToString();
            path = path.Replace("~/", "0");
            if (Allowed(path, "w"))
            {
                string destPath = path;//Server.MapPath(path);
                TB_Tree_ObjectBiz objTree = new TB_Tree_ObjectBiz();
                string mainPath = "";
                bool result = objTree.PersonAddDir(mainPath, path, name, userId);

                JsonResponse response = new JsonResponse();
                response.success = result;
                response.data = path;
                if (result)
                {
                    response.message = string.Format(lang_server.Get("Folder") + "[{0}]" + lang_server.Get("Successfully created"), name);
                }
                else
                {
                    response.message = string.Format(lang_server.Get("Folder") + "[{0}]" + lang_server.Get("Creation failed="), name);
                }

                return response;
            }
            else
            {
                JsonResponse response = new JsonResponse();
                response.success = false;
                response.message = string.Format(lang_server.Get("The folder 0 to be protected, you cannot add a folder to the"), path);
                return response;
            }
        }


        /// <summary>
        /// 个人文件夹重命名
        /// </summary>
        /// <param name="path"></param>
        /// <param name="newName"></param>
        /// <returns></returns>
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public JsonResponse individualRenameWJJ(string path, string newName)
        {
            JsonResponse response = new JsonResponse();
            response.success = true;
            string fileId = path;
            try
            {
                TB_Tree_ObjectBiz fileBiz = new TB_Tree_ObjectBiz();

                TB_Tree_ObjectInfo fileInfo = new TB_Tree_ObjectInfo();
                DataTable dt = fileBiz.GetTree_Person(fileId);
                if (dt.Rows.Count > 0)
                {
                    fileInfo.ObjectName = newName;
                    fileInfo.ObjectID = int.Parse(dt.Rows[0]["OBJ_ID"].ToString());
                    response.data = dt.Rows[0]["OBJ_ID"];
                    fileBiz.PersonlRename(fileInfo);
                    response.message = lang_server.Get("Rename success");
                }
                else
                {
                    response.message = lang_server.Get("Rename failed");
                }

            }
            catch (Exception ex)
            {
                response.success = false;
                response.message = ex.Message;
            }

            return response;
        }

        //个人空间文件重命名
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public JsonResponse individualRenameWJ(string path, string newName)
        {
            JsonResponse response = new JsonResponse();
            response.success = true;
            string fileId = path;
            try
            {
                TB_PERSON_FILEBiz fileBiz = new TB_PERSON_FILEBiz();
                TB_PERSON_FILEInfo fileInfo = fileBiz.GetFileInfoById(fileId);
                fileInfo.FILE_NAME = newName;
                response.data = fileInfo.FOLDER_ID;
                fileBiz.Update(fileInfo);
                response.message = lang_server.Get("Rename success");
            }
            catch (Exception ex)
            {
                response.success = false;
                response.message = ex.Message;
            }

            return response;
        }


        //个人空间文件夹移动
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public JsonResponse PersonCutWJJ(string paths, string newPath)
        {
            JsonResponse response = new JsonResponse();
            response.success = true;
            newPath = newPath.Replace("~/", "");
            string fileId = paths;
            try
            {
                TB_Tree_ObjectBiz fileBiz = new TB_Tree_ObjectBiz();

                TB_Tree_ObjectInfo fileInfo = new TB_Tree_ObjectInfo();
                DataTable dt = fileBiz.GetTree_Person(fileId);
                if (dt.Rows.Count > 0)
                {
                    response.data = fileInfo.ObjectID;// fileInfo.DEST_OBJ;

                    fileInfo.ObjectID = Convert.ToInt32(paths);
                    fileInfo.PObjectID = Convert.ToInt32(newPath);
                    fileBiz.UpdateTree_PersonCUT(fileInfo);

                    response.message = lang_server.Get("move succeeded");
                }
                else
                {
                    response.message = lang_server.Get("Failed to move");
                }
            }
            catch (Exception ex)
            {
                response.success = false;
                response.message = ex.Message;
            }

            return response;
        }

        //个人空间文件移动
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public JsonResponse PersonCutWJ(string paths, string newPath)
        {
            JsonResponse response = new JsonResponse();
            response.success = true;
            newPath = newPath.Replace("~/", "");
            string fileId = paths;
            try
            {
                TB_PERSON_FILEBiz fileBiz = new TB_PERSON_FILEBiz();
                TB_PERSON_FILEInfo fileInfo = fileBiz.GetFileInfoById(fileId);
                response.data = fileInfo.FOLDER_ID;// fileInfo.DEST_OBJ;

                fileInfo.FOLDER_ID = newPath;
                fileBiz.Update(fileInfo);

                response.message = lang_server.Get("move succeeded");
            }
            catch (Exception ex)
            {
                response.success = false;
                response.message = ex.Message;
            }

            return response;
        }

        //空间批量移动文件
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public JsonResponse CutDatas(string IDS, string newIDS, string SpaceType)
        {
            JsonResponse response = new JsonResponse();
            response.success = true;
            newIDS = newIDS.Replace("~/", "");
            IDS = IDS.Remove(IDS.LastIndexOf(","), 1);
            string fileId = IDS;
            try
            {
                if (SpaceType == "individual")
                {
                    TB_PERSON_FILEBiz fileBiz = new TB_PERSON_FILEBiz();
                    DataTable dt = fileBiz.GetModelList(fileId);
                    TB_PERSON_FILEInfo fileInfo = new TB_PERSON_FILEInfo();

                    if (dt.Rows.Count > 0)
                    {
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            fileInfo = new TB_PERSON_FILEInfo();
                            fileInfo.FILE_ID = Convert.ToDecimal(dt.Rows[i]["FILE_ID"].ToString());
                            fileInfo.FILE_NAME = dt.Rows[i]["FILE_NAME"].ToString();
                            fileInfo.FILE_EXT = dt.Rows[i]["FILE_EXT"].ToString();
                            fileInfo.FILE_CRT_DATE = Convert.ToDateTime(dt.Rows[i]["FILE_CRT_DATE"].ToString());
                            fileInfo.KEYW = dt.Rows[i]["KEYW"].ToString();
                            fileInfo.UPD_TIME = Convert.ToDateTime(dt.Rows[i]["UPD_TIME"].ToString());
                            fileInfo.FILE_TYPE = dt.Rows[i]["FILE_TYPE"].ToString();
                            fileInfo.FILE_ABST = dt.Rows[i]["FILE_ABST"].ToString();
                            fileInfo.CREATE_TIME = Convert.ToDateTime(dt.Rows[i]["CREATE_TIME"].ToString());
                            fileInfo.SAVE_PATH = dt.Rows[i]["SAVE_PATH"].ToString();
                            fileInfo.USER_ID = dt.Rows[i]["USER_ID"].ToString();
                            fileInfo.FILE_AUTHOR = dt.Rows[i]["FILE_AUTHOR"].ToString();
                            fileInfo.FILE_VERSION = Convert.ToDecimal(dt.Rows[i]["FILE_VERSION"].ToString());
                            fileInfo.FILE_SIZE = dt.Rows[i]["FILE_SIZE"].ToString();
                            fileInfo.DOWN_AMOUNT = Convert.ToDecimal(dt.Rows[i]["DOWN_AMOUNT"].ToString());
                            fileInfo.DEST_OBJ = dt.Rows[i]["DEST_OBJ"].ToString();
                            fileInfo.BIZ_OBJ = dt.Rows[i]["BIZ_OBJ"].ToString();
                            fileInfo.SECRET_LVL = dt.Rows[i]["SECRET_LVL"].ToString();
                            fileInfo.LANG_TYPE = Convert.ToDecimal(dt.Rows[i]["LANG_TYPE"].ToString());
                            fileInfo.PDF_PATH = dt.Rows[i]["PDF_PATH"].ToString();
                            fileInfo.SWF_PATH = dt.Rows[i]["SWF_PATH"].ToString();
                            fileInfo.FOLDER_ID = newIDS;
                            fileBiz.Update(fileInfo);
                            response.data = dt.Rows[i]["FOLDER_ID"];
                        }
                    }
                    response.message = lang_server.Get("move succeeded");
                }
                else if (SpaceType == "group")
                {
                    TB_TEAM_FILEBiz fileBiz = new TB_TEAM_FILEBiz();
                    TB_TEAM_FILEInfo fileInfo;

                    DataTable dt = fileBiz.GetModelList(fileId);
                    if (dt.Rows.Count > 0)
                    {
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            fileInfo = new TB_TEAM_FILEInfo();
                            fileInfo.FILE_ID = Convert.ToInt32(dt.Rows[i]["FILE_ID"].ToString());
                            fileInfo.TEAM_ID = int.Parse(dt.Rows[i]["TEAM_ID"].ToString());
                            fileInfo.FILE_NAME = dt.Rows[i]["FILE_NAME"].ToString();
                            fileInfo.FILE_EXT = dt.Rows[i]["FILE_EXT"].ToString();
                            fileInfo.FILE_ABST = dt.Rows[i]["FILE_ABST"].ToString();
                            fileInfo.FILE_AUTHOR = dt.Rows[i]["FILE_AUTHOR"].ToString();
                            fileInfo.KEYW = dt.Rows[i]["KEYW"].ToString();
                            fileInfo.FILE_CRT_TIME = Convert.ToDateTime(dt.Rows[i]["FILE_CRT_TIME"].ToString());
                            fileInfo.FILE_SIZE = dt.Rows[i]["FILE_SIZE"].ToString();
                            fileInfo.DOWN_AMOUNT = Convert.ToDecimal(dt.Rows[i]["DOWN_AMOUNT"].ToString());
                            fileInfo.DEST_OBJ = dt.Rows[i]["DEST_OBJ"].ToString();
                            fileInfo.BIZ_OBJ = dt.Rows[i]["BIZ_OBJ"].ToString();
                            fileInfo.SECRET_LVL = dt.Rows[i]["SECRET_LVL"].ToString();
                            fileInfo.LANG_TYPE = Convert.ToDecimal(dt.Rows[i]["LANG_TYPE"].ToString());
                            fileInfo.FILE_TYPE = dt.Rows[i]["FILE_TYPE"].ToString();
                            fileInfo.SAVE_PATH = dt.Rows[i]["SAVE_PATH"].ToString();
                            fileInfo.USER_ID = dt.Rows[i]["USER_ID"].ToString();
                            fileInfo.STATUS = int.Parse(dt.Rows[i]["STATUS"].ToString());
                            fileInfo.CREATE_TIME = Convert.ToDateTime(dt.Rows[i]["CREATE_TIME"].ToString());
                            fileInfo.UPD_TIME = Convert.ToDateTime(dt.Rows[i]["UPD_TIME"].ToString());
                            fileInfo.SINGLERECEIPT = "";
                            fileInfo.PDF_PATH = dt.Rows[i]["PDF_PATH"].ToString();
                            fileInfo.SWF_PATH = dt.Rows[i]["SWF_PATH"].ToString();
                            fileInfo.FOLDER_ID = newIDS;
                            fileBiz.Update(fileInfo);

                            response.data = dt.Rows[i]["FOLDER_ID"];
                        }
                    }
                    response.message = lang_server.Get("move succeeded");
                }
                else if (SpaceType == "project")
                {
                    Tb_Xmk_FileBiz fileBiz = new Tb_Xmk_FileBiz();
                    TB_XMK_FILEInfo fileInfo;
                    DataTable dt = fileBiz.GetModelList(fileId);

                    if (dt.Rows.Count > 0)
                    {
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            fileInfo = new TB_XMK_FILEInfo();
                            fileInfo.FILE_ID = Convert.ToDecimal(dt.Rows[i]["FILE_ID"].ToString());
                            fileInfo.TEAM_ID = int.Parse(dt.Rows[i]["TEAM_ID"].ToString());
                            fileInfo.FILE_NAME = dt.Rows[i]["FILE_NAME"].ToString();
                            fileInfo.FILE_EXT = dt.Rows[i]["FILE_EXT"].ToString();
                            fileInfo.FILE_ABST = dt.Rows[i]["FILE_ABST"].ToString();
                            fileInfo.FILE_AUTHOR = dt.Rows[i]["FILE_AUTHOR"].ToString();
                            fileInfo.KEYW = dt.Rows[i]["KEYW"].ToString();
                            fileInfo.FILE_CRT_DATE = Convert.ToDateTime(dt.Rows[i]["FILE_CRT_DATE"].ToString());
                            fileInfo.FILE_VERSION = Convert.ToDecimal(dt.Rows[i]["FILE_VERSION"]);
                            fileInfo.FILE_SIZE = dt.Rows[i]["FILE_SIZE"].ToString();
                            fileInfo.DOWN_AMOUNT = Convert.ToDecimal(dt.Rows[i]["DOWN_AMOUNT"].ToString());
                            fileInfo.DEST_OBJ = dt.Rows[i]["DEST_OBJ"].ToString();
                            fileInfo.BIZ_OBJ = dt.Rows[i]["BIZ_OBJ"].ToString();
                            fileInfo.SECRET_LVL = dt.Rows[i]["SECRET_LVL"].ToString();
                            fileInfo.LANG_TYPE = Convert.ToDecimal(dt.Rows[i]["LANG_TYPE"].ToString());
                            fileInfo.FILE_TYPE = dt.Rows[i]["FILE_TYPE"].ToString();
                            fileInfo.SAVE_PATH = dt.Rows[i]["SAVE_PATH"].ToString();
                            fileInfo.USER_ID = dt.Rows[i]["USER_ID"].ToString();
                            fileInfo.STATUS = Convert.ToDecimal(dt.Rows[i]["STATUS"].ToString());
                            fileInfo.CREATE_TIME = Convert.ToDateTime(dt.Rows[i]["CREATE_TIME"].ToString());
                            fileInfo.UPD_TIME = Convert.ToDateTime(dt.Rows[i]["UPD_TIME"].ToString());
                            fileInfo.FOLDER_ID = Convert.ToUInt32(newIDS);
                            response.data = dt.Rows[i]["FOLDER_ID"];
                            fileBiz.Update(fileInfo);
                        }
                    }
                    response.message = lang_server.Get("move succeeded");
                }

            }
            catch (Exception ex)
            {
                response.success = false;
                response.message = ex.Message;
            }

            return response;
        }

        //空间批量复制文件
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public JsonResponse CopyDatas(string IDS, string newIDS, string SpaceType)
        {
            JsonResponse response = new JsonResponse();
            response.success = true;
            newIDS = newIDS.Replace("~/", "");
            IDS = IDS.Remove(IDS.LastIndexOf(","), 1);
            string fileId = IDS;
            //根据日期建立新的文件夹
            string FolderName = System.DateTime.Now.ToString("yyyyMMdd");
            string DiskPath = ConfigurationManager.AppSettings["DiskPath"];
            try
            {
                if (SpaceType == "individual")
                {
                    TB_PERSON_FILEBiz fileBiz = new TB_PERSON_FILEBiz();
                    DataTable dt = fileBiz.GetModelList(fileId);
                    TB_PERSON_FILEInfo fileInfo = new TB_PERSON_FILEInfo();

                    if (dt.Rows.Count > 0)
                    {
                        string N_P_SOU_PATH = "";
                        string N_P_SWF_PATH = "";
                        string N_P_PDF_PATH = "";
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            string NewFileName = DateTime.Now.ToFileTimeUtc().ToString() + i.ToString();
                            fileInfo = new TB_PERSON_FILEInfo();

                            fileInfo.FILE_NAME = dt.Rows[i]["FILE_NAME"].ToString();
                            fileInfo.FILE_EXT = dt.Rows[i]["FILE_EXT"].ToString();
                            fileInfo.FILE_CRT_DATE = Convert.ToDateTime(dt.Rows[i]["FILE_CRT_DATE"].ToString());
                            fileInfo.KEYW = dt.Rows[i]["KEYW"].ToString();
                            fileInfo.UPD_TIME = Convert.ToDateTime(dt.Rows[i]["UPD_TIME"].ToString());
                            fileInfo.FILE_TYPE = dt.Rows[i]["FILE_TYPE"].ToString();
                            fileInfo.FILE_ABST = dt.Rows[i]["FILE_ABST"].ToString();
                            fileInfo.CREATE_TIME = Convert.ToDateTime(dt.Rows[i]["CREATE_TIME"].ToString());
                            fileInfo.USER_ID = dt.Rows[i]["USER_ID"].ToString();
                            fileInfo.FILE_AUTHOR = dt.Rows[i]["FILE_AUTHOR"].ToString();
                            fileInfo.FILE_SIZE = dt.Rows[i]["FILE_SIZE"].ToString();
                            fileInfo.DOWN_AMOUNT = Convert.ToDecimal(dt.Rows[i]["DOWN_AMOUNT"].ToString());
                            fileInfo.DEST_OBJ = dt.Rows[i]["DEST_OBJ"].ToString();
                            fileInfo.BIZ_OBJ = dt.Rows[i]["BIZ_OBJ"].ToString();
                            fileInfo.SECRET_LVL = dt.Rows[i]["SECRET_LVL"].ToString();
                            fileInfo.LANG_TYPE = Convert.ToDecimal(dt.Rows[i]["LANG_TYPE"].ToString());
                            fileInfo.FOLDER_ID = newIDS;
                            fileInfo.FILE_VERSION = fileBiz.GetMaxFileVersion(fileInfo.FILE_NAME, dt.Rows[0]["USER_ID"].ToString()) + 1;

                            //新文件名
                            N_P_SOU_PATH = "Individual/" + FolderName + "/" + NewFileName + fileInfo.FILE_NAME.Substring(fileInfo.FILE_NAME.LastIndexOf("."));
                            //pdf文件
                            if (!string.IsNullOrEmpty(dt.Rows[i]["PDF_PATH"].ToString()))
                            {
                                N_P_PDF_PATH = "PDF/Individual/" + FolderName + "/" + NewFileName + ".pdf";
                            }
                            //swf文件
                            if (!string.IsNullOrEmpty(dt.Rows[i]["SWF_PATH"].ToString()))
                            {
                                N_P_SWF_PATH = "SWF/Individual/" + FolderName + "/" + NewFileName + "/";
                            }

                            fileInfo.SAVE_PATH = N_P_SOU_PATH;
                            fileInfo.PDF_PATH = N_P_PDF_PATH;
                            fileInfo.SWF_PATH = N_P_SWF_PATH;
                            //数据添加成功复制文件
                            if (fileBiz.CopyFile(fileInfo))
                            {
                                //原文件
                                if (!Directory.Exists(DiskPath + "Individual/" + FolderName))
                                    Directory.CreateDirectory(DiskPath + "Individual/" + FolderName);

                                FileHelper.CopyFile1(DiskPath + dt.Rows[i]["SAVE_PATH"].ToString(), DiskPath + N_P_SOU_PATH);

                                //pdf文件
                                if (!string.IsNullOrEmpty(dt.Rows[i]["PDF_PATH"].ToString()))
                                {
                                    if (!Directory.Exists(DiskPath + "PDF/Individual/" + FolderName))
                                        Directory.CreateDirectory(DiskPath + "PDF/Individual/" + FolderName);

                                    FileHelper.CopyFile1(DiskPath + dt.Rows[i]["PDF_PATH"].ToString(), DiskPath + N_P_PDF_PATH);
                                }

                                //swf文件
                                if (!string.IsNullOrEmpty(dt.Rows[i]["SWF_PATH"].ToString()))
                                {
                                    if (!Directory.Exists(DiskPath + "SWF/Individual/" + FolderName + "/" + NewFileName))
                                        Directory.CreateDirectory(DiskPath + "SWF/Individual/" + FolderName + "/" + NewFileName);

                                    CopyFile(DiskPath + dt.Rows[i]["SWF_PATH"].ToString(), DiskPath + N_P_SWF_PATH);
                                }

                            }
                            response.data = dt.Rows[i]["FOLDER_ID"];
                        }
                    }
                    response.message = lang_server.Get("Copy success");
                }
                else if (SpaceType == "group")
                {
                    TB_TEAM_FILEBiz fileBiz = new TB_TEAM_FILEBiz();
                    TB_TEAM_FILEInfo fileInfo;

                    DataTable dt = fileBiz.GetModelList(fileId);
                    if (dt.Rows.Count > 0)
                    {
                        string N_T_SOU_PATH = "";
                        string N_T_SWF_PATH = "";
                        string N_T_PDF_PATH = "";

                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            string NewFileName = DateTime.Now.ToFileTimeUtc().ToString() + i.ToString();
                            fileInfo = new TB_TEAM_FILEInfo();

                            fileInfo.TEAM_ID = int.Parse(dt.Rows[i]["TEAM_ID"].ToString());
                            fileInfo.FILE_NAME = dt.Rows[i]["FILE_NAME"].ToString();
                            fileInfo.FILE_EXT = dt.Rows[i]["FILE_EXT"].ToString();
                            fileInfo.FILE_ABST = dt.Rows[i]["FILE_ABST"].ToString();
                            fileInfo.FILE_AUTHOR = dt.Rows[i]["FILE_AUTHOR"].ToString();
                            fileInfo.KEYW = dt.Rows[i]["KEYW"].ToString();
                            fileInfo.FILE_CRT_TIME = Convert.ToDateTime(dt.Rows[i]["FILE_CRT_TIME"].ToString());
                            fileInfo.FILE_SIZE = dt.Rows[i]["FILE_SIZE"].ToString();
                            fileInfo.DOWN_AMOUNT = Convert.ToDecimal(dt.Rows[i]["DOWN_AMOUNT"].ToString());
                            fileInfo.DEST_OBJ = dt.Rows[i]["DEST_OBJ"].ToString();
                            fileInfo.BIZ_OBJ = dt.Rows[i]["BIZ_OBJ"].ToString();
                            fileInfo.SECRET_LVL = dt.Rows[i]["SECRET_LVL"].ToString();
                            fileInfo.LANG_TYPE = Convert.ToDecimal(dt.Rows[i]["LANG_TYPE"].ToString());
                            fileInfo.FILE_TYPE = dt.Rows[i]["FILE_TYPE"].ToString();
                            fileInfo.SAVE_PATH = dt.Rows[i]["SAVE_PATH"].ToString();
                            fileInfo.USER_ID = dt.Rows[i]["USER_ID"].ToString();
                            fileInfo.STATUS = int.Parse(dt.Rows[i]["STATUS"].ToString());
                            fileInfo.CREATE_TIME = Convert.ToDateTime(dt.Rows[i]["CREATE_TIME"].ToString());
                            fileInfo.UPD_TIME = Convert.ToDateTime(dt.Rows[i]["UPD_TIME"].ToString());
                            fileInfo.SINGLERECEIPT = "";
                            //fileInfo.PDF_PATH = dt.Rows[i]["PDF_PATH"].ToString();
                            //fileInfo.SWF_PATH = dt.Rows[i]["SWF_PATH"].ToString();
                            fileInfo.FOLDER_ID = newIDS;
                            fileInfo.FILE_VERSION = fileBiz.GetMaxFileTeam(fileInfo.FILE_NAME, dt.Rows[0]["TEAM_ID"].ToString()) + 1;

                            //新文件名
                            N_T_SOU_PATH = "Group/" + FolderName + "/" + NewFileName + fileInfo.FILE_NAME.Substring(fileInfo.FILE_NAME.LastIndexOf("."));
                            //pdf文件
                            if (!string.IsNullOrEmpty(dt.Rows[i]["PDF_PATH"].ToString()))
                            {
                                N_T_PDF_PATH = "PDF/Group/" + FolderName + "/" + NewFileName + ".pdf";
                            }
                            //swf文件
                            if (!string.IsNullOrEmpty(dt.Rows[i]["SWF_PATH"].ToString()))
                            {
                                N_T_SWF_PATH = "SWF/Group/" + FolderName + "/" + NewFileName + "/";
                            }

                            fileInfo.SAVE_PATH = N_T_SOU_PATH;
                            fileInfo.PDF_PATH = N_T_PDF_PATH;
                            fileInfo.SWF_PATH = N_T_SWF_PATH;
                            //数据添加成功复制文件
                            if (fileBiz.CopyFile(fileInfo))
                            {
                                //原文件
                                if (!Directory.Exists(DiskPath + "Group/" + FolderName))
                                    Directory.CreateDirectory(DiskPath + "Group/" + FolderName);

                                FileHelper.CopyFile1(DiskPath + dt.Rows[i]["SAVE_PATH"].ToString(), DiskPath + N_T_SOU_PATH);

                                //pdf文件
                                if (!string.IsNullOrEmpty(dt.Rows[i]["PDF_PATH"].ToString()))
                                {
                                    if (!Directory.Exists(DiskPath + "PDF/Group/" + FolderName))
                                        Directory.CreateDirectory(DiskPath + "PDF/Group/" + FolderName);

                                    FileHelper.CopyFile1(DiskPath + dt.Rows[i]["PDF_PATH"].ToString(), DiskPath + N_T_PDF_PATH);
                                }

                                //swf文件
                                if (!string.IsNullOrEmpty(dt.Rows[i]["SWF_PATH"].ToString()))
                                {
                                    if (!Directory.Exists(DiskPath + "SWF/Group/" + FolderName + "/" + NewFileName))
                                        Directory.CreateDirectory(DiskPath + "SWF/Group/" + FolderName + "/" + NewFileName);

                                    CopyFile(DiskPath + dt.Rows[i]["SWF_PATH"].ToString(), DiskPath + N_T_SWF_PATH);
                                }

                            }

                            response.data = dt.Rows[i]["FOLDER_ID"];
                        }
                    }
                    response.message = lang_server.Get("Copy success");
                }
                else if (SpaceType == "project")
                {
                    Tb_Xmk_FileBiz fileBiz = new Tb_Xmk_FileBiz();
                    TB_XMK_FILEInfo fileInfo;
                    DataTable dt = fileBiz.GetModelList(fileId);

                    if (dt.Rows.Count > 0)
                    {
                        string N_X_SOU_PATH = "";
                        string N_X_SWF_PATH = "";
                        string N_X_PDF_PATH = "";
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            string NewFileName = DateTime.Now.ToFileTimeUtc().ToString() + i.ToString();
                            fileInfo = new TB_XMK_FILEInfo();

                            fileInfo.TEAM_ID = int.Parse(dt.Rows[i]["TEAM_ID"].ToString());
                            fileInfo.FILE_NAME = dt.Rows[i]["FILE_NAME"].ToString();
                            fileInfo.FILE_EXT = dt.Rows[i]["FILE_EXT"].ToString();
                            fileInfo.FILE_ABST = dt.Rows[i]["FILE_ABST"].ToString();
                            fileInfo.FILE_AUTHOR = dt.Rows[i]["FILE_AUTHOR"].ToString();
                            fileInfo.KEYW = dt.Rows[i]["KEYW"].ToString();
                            fileInfo.FILE_SIZE = dt.Rows[i]["FILE_SIZE"].ToString();
                            fileInfo.DOWN_AMOUNT = Convert.ToDecimal(dt.Rows[i]["DOWN_AMOUNT"].ToString());
                            fileInfo.DEST_OBJ = dt.Rows[i]["DEST_OBJ"].ToString();
                            fileInfo.BIZ_OBJ = dt.Rows[i]["BIZ_OBJ"].ToString();
                            fileInfo.SECRET_LVL = dt.Rows[i]["SECRET_LVL"].ToString();
                            fileInfo.LANG_TYPE = Convert.ToDecimal(dt.Rows[i]["LANG_TYPE"].ToString());
                            fileInfo.FILE_TYPE = dt.Rows[i]["FILE_TYPE"].ToString();
                            fileInfo.SAVE_PATH = dt.Rows[i]["SAVE_PATH"].ToString();
                            fileInfo.USER_ID = dt.Rows[i]["USER_ID"].ToString();
                            fileInfo.STATUS = Convert.ToDecimal(dt.Rows[i]["STATUS"].ToString());
                            fileInfo.CREATE_TIME = Convert.ToDateTime(dt.Rows[i]["CREATE_TIME"].ToString());
                            fileInfo.UPD_TIME = Convert.ToDateTime(dt.Rows[i]["UPD_TIME"].ToString());
                            fileInfo.FOLDER_ID = Convert.ToUInt32(newIDS);
                            fileInfo.FILE_VERSION = fileBiz.GetMaxFileVersionXmk(fileInfo.FILE_NAME) + 1;



                            //新文件名
                            N_X_SOU_PATH = "Project/" + FolderName + "/" + NewFileName + fileInfo.FILE_NAME.Substring(fileInfo.FILE_NAME.LastIndexOf("."));
                            //pdf文件
                            if (!string.IsNullOrEmpty(dt.Rows[i]["PDF_PATH"].ToString()))
                            {
                                N_X_PDF_PATH = "PDF/Project/" + FolderName + "/" + NewFileName + ".pdf";
                            }
                            //swf文件
                            if (!string.IsNullOrEmpty(dt.Rows[i]["SWF_PATH"].ToString()))
                            {
                                N_X_SWF_PATH = "SWF/Project/" + FolderName + "/" + NewFileName + "/";
                            }

                            fileInfo.SAVE_PATH = N_X_SOU_PATH;
                            fileInfo.PDF_PATH = N_X_PDF_PATH;
                            fileInfo.SWF_PATH = N_X_SWF_PATH;
                            //数据添加成功复制文件
                            if (fileBiz.Upload(fileInfo))
                            {
                                //原文件
                                if (!Directory.Exists(DiskPath + "Project/" + FolderName))
                                    Directory.CreateDirectory(DiskPath + "Project/" + FolderName);

                                FileHelper.CopyFile1(DiskPath + dt.Rows[i]["SAVE_PATH"].ToString(), DiskPath + N_X_SOU_PATH);

                                //pdf文件
                                if (!string.IsNullOrEmpty(dt.Rows[i]["SWF_PATH"].ToString()))
                                {
                                    if (!Directory.Exists(DiskPath + "PDF/Project/" + FolderName))
                                        Directory.CreateDirectory(DiskPath + "PDF/Project/" + FolderName);

                                    FileHelper.CopyFile1(DiskPath + dt.Rows[i]["PDF_PATH"].ToString(), DiskPath + N_X_PDF_PATH);
                                }

                                //swf文件
                                if (!string.IsNullOrEmpty(dt.Rows[i]["SWF_PATH"].ToString()))
                                {
                                    if (!Directory.Exists(DiskPath + "SWF/Project/" + FolderName + "/" + NewFileName))
                                        Directory.CreateDirectory(DiskPath + "SWF/Project/" + FolderName + "/" + NewFileName);

                                    CopyFile(DiskPath + dt.Rows[i]["SWF_PATH"].ToString(), DiskPath + N_X_SWF_PATH);
                                }

                            }
                            response.data = dt.Rows[i]["FOLDER_ID"];


                        }
                    }
                    response.message = lang_server.Get("Copy success");
                }

            }
            catch (Exception ex)
            {
                response.success = false;
                response.message = ex.Message;
            }

            return response;
        }

        //个人空间文件复制
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public JsonResponse PersonCopyWJ(string paths, string newPath)
        {
            JsonResponse response = new JsonResponse();
            response.success = true;
            newPath = newPath.Replace("~/", "");
            string fileId = paths;
            try
            {
                TB_PERSON_FILEBiz fileBiz = new TB_PERSON_FILEBiz();
                TB_PERSON_FILEInfo fileInfo = fileBiz.GetFileInfoById(fileId);
                response.data = fileInfo.FOLDER_ID;

                fileInfo.FOLDER_ID = newPath;
                fileBiz.CopyFile(fileInfo);

                response.message = lang_server.Get("Copy success");
            }
            catch (Exception ex)
            {
                response.success = false;
                response.message = ex.Message;
            }

            return response;
        }


        //个人空间文件夹删除
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public JsonResponse PersonDeleteWJJ(string paths, bool recursive = false)
        {
            JsonResponse response = new JsonResponse();
            response.success = true;

            string fileId = paths;
            try
            {
                TB_PERSON_FILEBiz fileBiz = new TB_PERSON_FILEBiz();

                DataTable dt = fileBiz.GetPersonFile(fileId);
                // string dest_obj = Convert.ToString(dr["FOLDER_ID"]);
                TB_Tree_ObjectBiz fileBiz1 = new TB_Tree_ObjectBiz();
                DataTable dt2 = fileBiz1.GetTree_PersonP_ID(fileId);

                if (dt.Rows.Count > 0 || dt2.Rows.Count > 0)
                {
                    response.message = lang_server.Get("The folder cannot be deleted");
                    response.data = fileId;
                }
                else
                {
                    response.data = fileId;

                    if (fileBiz1.deleteTREE_PersonBySQL(fileId))
                    {
                        response.message = lang_server.Get("The folder is deleted successfully");
                    }
                    else
                    {
                        response.message = lang_server.Get("Failed to delete the folder");
                    }
                }
            }
            catch (Exception ex)
            {
                response.message = ex.Message;
            }

            return response;
        }


        //个人空间文件删除
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public JsonResponse PersonDeleteWJ(string paths, bool recursive = false)
        {
            JsonResponse response = new JsonResponse();
            response.success = true;

            string fileId = paths;
            try
            {
                TB_PERSON_FILEBiz fileBiz = new TB_PERSON_FILEBiz();
                TB_PERSON_FILEInfo dt = fileBiz.GetFileInfoById(fileId);
                //DataRow dr = dt.Rows[0];
                string dest_obj = dt.FOLDER_ID;


                response.data = dest_obj;

                string save_path = dt.SAVE_PATH;
                string file_name = dt.FILE_NAME;

                bool isMoreThanOne = fileBiz.IsMoreThanOne(paths);
                if (!isMoreThanOne)
                {
                    if (!fileBiz.HasSavePath(save_path))
                    {

                        //删除源文件
                        if (!string.IsNullOrEmpty(dt.SAVE_PATH))
                        {
                            string fileName = ConfigurationManager.AppSettings["DiskPath"] + dt.SAVE_PATH.ToString();
                            if (File.Exists(fileName))
                            {
                                File.Delete(fileName);
                            }
                        }
                        //删除pdf文件
                        if (!string.IsNullOrEmpty(dt.PDF_PATH))
                        {
                            string pdfPathName = ConfigurationManager.AppSettings["DiskPath"] + dt.PDF_PATH.ToString();
                            if (File.Exists(pdfPathName))
                            {
                                File.Delete(pdfPathName);
                            }

                        }
                        //删除swf文件
                        if (!string.IsNullOrEmpty(dt.SWF_PATH))
                        {
                            string swfPathName = ConfigurationManager.AppSettings["DiskPath"] + dt.SWF_PATH.ToString();
                            if (File.Exists(swfPathName))
                            {
                                File.Delete(swfPathName);
                            }
                        }
                    }
                }
                fileBiz.Delete(fileId);


                response.message = lang_server.Get("Files deleted successfully");
            }
            catch (Exception ex)
            {
                response.message = ex.Message;
            }

            return response;
        }

        //个人空间文件移动到回收站
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public JsonResponse PersonRemoveToRecycleWJ(string paths, bool recursive = false)
        {
            JsonResponse response = new JsonResponse();
            response.success = true;

            string fileId = paths;
            try
            {
                TB_PERSON_FILEBiz fileBiz = new TB_PERSON_FILEBiz();
                TB_PERSON_FILEInfo dt = fileBiz.GetFileInfoById(fileId);
                //DataRow dr = dt.Rows[0];
                string dest_obj = dt.FOLDER_ID;


                response.data = dest_obj;


                fileBiz.RemoveToRecycle(fileId);


                response.message = lang_server.Get("Files deleted successfully");
            }
            catch (Exception ex)
            {
                response.message = ex.Message;
            }

            return response;
        }

        #endregion Operate about Individual

        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public JsonResponse ConfirmHaveSameFile(string IDS, string newName, string SpaceType)
        {
            JsonResponse response = new JsonResponse();
            response.success = true;
            string fileId = IDS;
            try
            {
                decimal count = 0;
                if (SpaceType == "individual")
                {
                    TB_PERSON_FILEBiz fileBiz = new TB_PERSON_FILEBiz();
                    DataTable dt = fileBiz.GetModelList(fileId);
                    if (newName != dt.Rows[0]["FILE_NAME"].ToString())
                    {
                        count = fileBiz.GetMaxFileVersion(newName, dt.Rows[0]["USER_ID"].ToString());
                        if (count > 0)
                        {
                            response.success = false;

                        }
                    }
                }
                else if (SpaceType == "group")
                {
                    TB_TEAM_FILEBiz fileBiz = new TB_TEAM_FILEBiz();
                    DataTable dt = fileBiz.GetModelList(fileId);
                    if (newName != dt.Rows[0]["FILE_NAME"].ToString())
                    {
                        count = fileBiz.GetMaxFileTeam(newName, dt.Rows[0]["TEAM_ID"].ToString());
                        if (count > 0)
                        {
                            response.success = false;

                        }
                    }
                }
                else
                {
                    Tb_Xmk_FileBiz fileBiz = new Tb_Xmk_FileBiz();
                    DataTable dt = fileBiz.GetModelList(fileId);
                    if (newName != dt.Rows[0]["FILE_NAME"].ToString())
                    {
                        count = fileBiz.GetMaxFileVersionXmk(newName);
                        if (count > 0)
                        {
                            response.success = false;

                        }
                    }
                }
            }
            catch (Exception ex)
            {
                response.success = false;
                response.message = ex.Message;
            }

            return response;
        }

        /// <summary>
        /// 文件批量重命名
        /// </summary>
        /// <param name="path"></param>
        /// <param name="newName"></param>
        /// <returns></returns>
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public JsonResponse RenameDatas(string IDS, string newName, string SpaceType)
        {
            JsonResponse response = new JsonResponse();
            response.success = true;
            //IDS = IDS.Remove(IDS.LastIndexOf(","), 1);
            string fileId = IDS;
            decimal count;
            try
            {
                if (SpaceType == "individual")
                {
                    TB_PERSON_FILEBiz fileBiz = new TB_PERSON_FILEBiz();
                    DataTable dt = fileBiz.GetModelList(fileId);
                    TB_PERSON_FILEInfo fileInfo = new TB_PERSON_FILEInfo();

                    if (dt.Rows.Count > 0)
                    {
                        //    for (int i = 0; i < dt.Rows.Count; i++)
                        //    {
                        fileInfo = new TB_PERSON_FILEInfo();
                        fileInfo.FILE_ID = Convert.ToDecimal(dt.Rows[0]["FILE_ID"].ToString());
                        fileInfo.FILE_NAME = newName;
                        fileInfo.FILE_EXT = dt.Rows[0]["FILE_EXT"].ToString();
                        fileInfo.FILE_CRT_DATE = Convert.ToDateTime(dt.Rows[0]["FILE_CRT_DATE"].ToString());
                        fileInfo.KEYW = dt.Rows[0]["KEYW"].ToString();
                        fileInfo.UPD_TIME = Convert.ToDateTime(dt.Rows[0]["UPD_TIME"].ToString());
                        fileInfo.FILE_TYPE = dt.Rows[0]["FILE_TYPE"].ToString();
                        fileInfo.FILE_ABST = dt.Rows[0]["FILE_ABST"].ToString();
                        fileInfo.CREATE_TIME = Convert.ToDateTime(dt.Rows[0]["CREATE_TIME"].ToString());
                        fileInfo.SAVE_PATH = dt.Rows[0]["SAVE_PATH"].ToString();
                        fileInfo.USER_ID = dt.Rows[0]["USER_ID"].ToString();
                        fileInfo.FILE_AUTHOR = dt.Rows[0]["FILE_AUTHOR"].ToString();
                        fileInfo.FILE_SIZE = dt.Rows[0]["FILE_SIZE"].ToString();
                        fileInfo.DOWN_AMOUNT = Convert.ToDecimal(dt.Rows[0]["DOWN_AMOUNT"].ToString());
                        fileInfo.DEST_OBJ = dt.Rows[0]["DEST_OBJ"].ToString();
                        fileInfo.BIZ_OBJ = dt.Rows[0]["BIZ_OBJ"].ToString();
                        fileInfo.SECRET_LVL = dt.Rows[0]["SECRET_LVL"].ToString();
                        fileInfo.LANG_TYPE = Convert.ToDecimal(dt.Rows[0]["LANG_TYPE"].ToString());
                        fileInfo.PDF_PATH = dt.Rows[0]["PDF_PATH"].ToString();
                        fileInfo.SWF_PATH = dt.Rows[0]["SWF_PATH"].ToString();
                        fileInfo.FOLDER_ID = dt.Rows[0]["FOLDER_ID"].ToString();
                        if (newName != dt.Rows[0]["FILE_NAME"].ToString())
                        {
                            fileInfo.FILE_VERSION = fileBiz.GetMaxFileVersion(newName, dt.Rows[0]["USER_ID"].ToString()) + 1;
                        }
                        else
                        {
                            fileInfo.FILE_VERSION = Convert.ToDecimal(dt.Rows[0]["FILE_VERSION"]);
                        }

                        fileBiz.Update(fileInfo);
                        response.data = dt.Rows[0]["FOLDER_ID"];
                    }
                    //}
                    response.message = lang_server.Get("Rename success");

                }
                else if (SpaceType == "group")
                {
                    TB_TEAM_FILEBiz fileBiz = new TB_TEAM_FILEBiz();
                    TB_TEAM_FILEInfo fileInfo;

                    DataTable dt = fileBiz.GetModelList(fileId);

                    if (dt.Rows.Count > 0)
                    {
                        //    for (int i = 0; i < dt.Rows.Count; i++)
                        //    {
                        fileInfo = new TB_TEAM_FILEInfo();
                        fileInfo.FILE_ID = Convert.ToInt32(dt.Rows[0]["FILE_ID"].ToString());
                        fileInfo.TEAM_ID = int.Parse(dt.Rows[0]["TEAM_ID"].ToString());
                        fileInfo.FILE_NAME = newName;
                        fileInfo.FILE_EXT = dt.Rows[0]["FILE_EXT"].ToString();
                        fileInfo.FILE_ABST = dt.Rows[0]["FILE_ABST"].ToString();
                        fileInfo.FILE_AUTHOR = dt.Rows[0]["FILE_AUTHOR"].ToString();
                        fileInfo.KEYW = dt.Rows[0]["KEYW"].ToString();
                        fileInfo.FILE_CRT_TIME = Convert.ToDateTime(dt.Rows[0]["FILE_CRT_TIME"].ToString());
                        fileInfo.FILE_SIZE = dt.Rows[0]["FILE_SIZE"].ToString();
                        fileInfo.DOWN_AMOUNT = Convert.ToDecimal(dt.Rows[0]["DOWN_AMOUNT"].ToString());
                        fileInfo.DEST_OBJ = dt.Rows[0]["DEST_OBJ"].ToString();
                        fileInfo.BIZ_OBJ = dt.Rows[0]["BIZ_OBJ"].ToString();
                        fileInfo.SECRET_LVL = dt.Rows[0]["SECRET_LVL"].ToString();
                        fileInfo.LANG_TYPE = Convert.ToDecimal(dt.Rows[0]["LANG_TYPE"].ToString());
                        fileInfo.FILE_TYPE = dt.Rows[0]["FILE_TYPE"].ToString();
                        fileInfo.SAVE_PATH = dt.Rows[0]["SAVE_PATH"].ToString();
                        fileInfo.USER_ID = dt.Rows[0]["USER_ID"].ToString();
                        fileInfo.STATUS = int.Parse(dt.Rows[0]["STATUS"].ToString());
                        fileInfo.CREATE_TIME = Convert.ToDateTime(dt.Rows[0]["CREATE_TIME"].ToString());
                        fileInfo.UPD_TIME = Convert.ToDateTime(dt.Rows[0]["UPD_TIME"].ToString());
                        fileInfo.SINGLERECEIPT = "";
                        fileInfo.PDF_PATH = dt.Rows[0]["PDF_PATH"].ToString();
                        fileInfo.SWF_PATH = dt.Rows[0]["SWF_PATH"].ToString();
                        fileInfo.FOLDER_ID = dt.Rows[0]["FOLDER_ID"].ToString();
                        if (newName != dt.Rows[0]["FILE_NAME"].ToString())
                        {
                            fileInfo.FILE_VERSION = fileBiz.GetMaxFileTeam(newName, dt.Rows[0]["TEAM_ID"].ToString()) + 1;
                        }
                        else
                        {
                            fileInfo.FILE_VERSION = Convert.ToDecimal(dt.Rows[0]["FILE_VERSION"]);
                        }
                        fileBiz.Update(fileInfo);

                        response.data = dt.Rows[0]["FOLDER_ID"];
                    }
                    //}
                    response.message = lang_server.Get("Rename success");

                }
                else if (SpaceType == "project")
                {
                    Tb_Xmk_FileBiz fileBiz = new Tb_Xmk_FileBiz();
                    TB_XMK_FILEInfo fileInfo;
                    DataTable dt = fileBiz.GetModelList(fileId);

                    if (dt.Rows.Count > 0)
                    {
                        //for (int i = 0; i < dt.Rows.Count; i++)
                        //{
                        fileInfo = new TB_XMK_FILEInfo();
                        fileInfo.FILE_ID = Convert.ToDecimal(dt.Rows[0]["FILE_ID"].ToString());
                        fileInfo.TEAM_ID = int.Parse(dt.Rows[0]["TEAM_ID"].ToString());
                        fileInfo.FILE_NAME = newName;
                        fileInfo.FILE_EXT = dt.Rows[0]["FILE_EXT"].ToString();
                        fileInfo.FILE_ABST = dt.Rows[0]["FILE_ABST"].ToString();
                        fileInfo.FILE_AUTHOR = dt.Rows[0]["FILE_AUTHOR"].ToString();
                        fileInfo.KEYW = dt.Rows[0]["KEYW"].ToString();
                        fileInfo.FILE_CRT_DATE = Convert.ToDateTime(dt.Rows[0]["FILE_CRT_DATE"].ToString());
                        fileInfo.FILE_VERSION = Convert.ToDecimal(dt.Rows[0]["FILE_VERSION"].ToString());
                        fileInfo.FILE_SIZE = dt.Rows[0]["FILE_SIZE"].ToString();
                        fileInfo.DOWN_AMOUNT = Convert.ToDecimal(dt.Rows[0]["DOWN_AMOUNT"].ToString());
                        fileInfo.DEST_OBJ = dt.Rows[0]["DEST_OBJ"].ToString();
                        fileInfo.BIZ_OBJ = dt.Rows[0]["BIZ_OBJ"].ToString();
                        fileInfo.SECRET_LVL = dt.Rows[0]["SECRET_LVL"].ToString();
                        fileInfo.LANG_TYPE = Convert.ToDecimal(dt.Rows[0]["LANG_TYPE"].ToString());
                        fileInfo.FILE_TYPE = dt.Rows[0]["FILE_TYPE"].ToString();
                        fileInfo.SAVE_PATH = dt.Rows[0]["SAVE_PATH"].ToString();
                        fileInfo.USER_ID = dt.Rows[0]["USER_ID"].ToString();
                        fileInfo.STATUS = Convert.ToDecimal(dt.Rows[0]["STATUS"].ToString());
                        fileInfo.CREATE_TIME = Convert.ToDateTime(dt.Rows[0]["CREATE_TIME"].ToString());
                        fileInfo.UPD_TIME = Convert.ToDateTime(dt.Rows[0]["UPD_TIME"].ToString());
                        fileInfo.FOLDER_ID = Convert.ToUInt32(dt.Rows[0]["FOLDER_ID"].ToString());
                        if (newName != dt.Rows[0]["FILE_NAME"].ToString())
                        {
                            fileInfo.FILE_VERSION = fileBiz.GetMaxFileVersionXmk(newName) + 1;
                        }
                        else
                        {
                            fileInfo.FILE_VERSION = Convert.ToDecimal(dt.Rows[0]["FILE_VERSION"]);
                        }
                        response.data = dt.Rows[0]["FOLDER_ID"];
                        fileBiz.Update(fileInfo);
                        //}
                    }
                    response.message = lang_server.Get("Rename success");
                }

            }
            catch (Exception ex)
            {
                response.success = false;
                response.message = ex.Message;
            }

            return response;
        }



        /// <summary>
        /// 重命名文件，或者文件夹
        /// </summary>
        /// <param name="path"></param>
        /// <param name="newName"></param>
        /// <returns></returns>
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public JsonResponse Rename(string path, string newName)
        {
            string userId = Context.Request.Cookies["user_id"].Value;
            if (Session != null && Session["sub_path"] != null)
                config.SubPath = Session["sub_path"].ToString();

            path = path.Replace("~/", config.FilesPath);//("~", config.BasePath);
            if (Allowed(path, "w"))
            {
                // DirectoryInfo dirInfo = new DirectoryInfo(path);
                if (Directory.Exists(path))
                {
                    DirectoryInfo dirInfo = new DirectoryInfo(path);
                    if (dirInfo.GetFiles().Count() > 0 || dirInfo.GetDirectories().Count() > 0)
                    {
                        JsonResponse response = new JsonResponse();
                        response.success = false;
                        response.message = lang_server.Get("The directory is not empty, can not be rename");
                        return response;
                    }
                    TB_Tree_ObjectBiz objTree = new TB_Tree_ObjectBiz();
                    string mainPath = config.FilesPath;
                    objTree.Rename(mainPath, path, newName);
                }
                else
                {
                    TB_PERSON_FILEBiz fileBiz = new TB_PERSON_FILEBiz();
                    string modelPath = path.Substring(path.IndexOf(config.SubPath));
                    string modelName = modelPath.Substring(modelPath.LastIndexOf('/') + 1);
                    modelPath = modelPath.Replace('/' + modelName, "");
                    TB_PERSON_FILEInfo fileObj = fileBiz.GetFileInfoBy_PathAndName(modelPath, modelName, userId);
                    fileObj.FILE_NAME = newName;
                    fileObj.UPD_TIME = DateTime.Now;
                    fileBiz.Update(fileObj);
                }
                return FileHelper.Rename(path, newName);
            }
            else
            {
                JsonResponse response = new JsonResponse();
                response.success = false;
                response.message = lang_server.Get("Cannot modify these files or folders");
                return response;
            }
        }
        /// <summary>
        /// 剪切
        /// </summary>
        /// <param name="paths"></param>
        /// <param name="newPath"></param>
        /// <returns></returns>
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public JsonResponse Cut(string paths, string newPath)
        {
            string userId = Context.Request.Cookies["user_id"].Value;
            if (Session != null && Session["sub_path"] != null)
                config.SubPath = Session["sub_path"].ToString();
            paths = paths.Replace("~/", GetBasePath());
            newPath = newPath.Replace("~/", config.FilesPath);
            //newPath = Server.MapPath(newPath);
            TB_PERSON_FILEBiz fileBiz = new TB_PERSON_FILEBiz();
            string modelPath = paths.Substring(paths.IndexOf(config.SubPath));
            string newModelPath = newPath.Substring(newPath.IndexOf(config.SubPath));
            if (newModelPath.EndsWith("/"))
            {
                newModelPath = newModelPath.Substring(0, newModelPath.Length - 1);
            }
            string modelName = modelPath.Substring(modelPath.LastIndexOf('/') + 1);
            modelPath = modelPath.Replace('/' + modelName, "");
            TB_PERSON_FILEInfo fileObj = fileBiz.GetFileInfoBy_PathAndName(modelPath, modelName, userId);
            fileObj.SAVE_PATH = newModelPath;
            fileObj.UPD_TIME = DateTime.Now;

            if (!String.IsNullOrEmpty(fileObj.PDF_PATH))
            {
                string pdfPathName = ConfigurationManager.AppSettings["DiskPath"] + fileObj.PDF_PATH;
                string pdfFileName = fileObj.PDF_PATH;
                pdfFileName = pdfFileName.Substring(pdfFileName.LastIndexOf('/') + 1);
                fileObj.PDF_PATH = newModelPath + "/" + pdfFileName;
                File.Copy(pdfPathName, ConfigurationManager.AppSettings["DiskPath"] + fileObj.PDF_PATH);
                File.Delete(pdfPathName);
            }
            if (!String.IsNullOrEmpty(fileObj.SWF_PATH))
            {
                string swfPathName = ConfigurationManager.AppSettings["DiskPath"] + fileObj.SWF_PATH;
                string swfFileName = fileObj.SWF_PATH;
                swfFileName = swfFileName.Substring(swfFileName.LastIndexOf('/') + 1);
                fileObj.SWF_PATH = newModelPath + "/" + swfFileName;
                File.Copy(swfPathName, ConfigurationManager.AppSettings["DiskPath"] + fileObj.SWF_PATH);
                File.Delete(swfPathName);
            }

            fileBiz.Update(fileObj);
            return FileHelper.Cut(paths, newPath);
        }
        /// <summary>
        /// 复制
        /// </summary>
        /// <param name="paths"></param>
        /// <param name="newPath"></param>
        /// <returns></returns>
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public JsonResponse Copy(string paths, string newPath)
        {

            string userId = Context.Request.Cookies["user_id"].Value;
            if (Session != null && Session["sub_path"] != null)
                config.SubPath = Session["sub_path"].ToString();
            paths = paths.Replace("~/", GetBasePath());
            newPath = newPath.Replace("~/", config.FilesPath);

            TB_PERSON_FILEBiz fileBiz = new TB_PERSON_FILEBiz();
            string modelPath = paths.Substring(paths.IndexOf(config.SubPath));
            string newModelPath = newPath.Substring(newPath.IndexOf(config.SubPath));
            if (newModelPath.EndsWith("/"))
            {
                newModelPath = newModelPath.Substring(0, newModelPath.Length - 1);
            }
            string modelName = modelPath.Substring(modelPath.LastIndexOf('/') + 1);
            modelPath = modelPath.Replace('/' + modelName, "");
            TB_PERSON_FILEInfo fileObj = fileBiz.GetFileInfoBy_PathAndName(modelPath, modelName, userId);
            fileObj.SAVE_PATH = newModelPath;
            fileObj.UPD_TIME = DateTime.Now;
            if (!String.IsNullOrEmpty(fileObj.PDF_PATH))
            {
                string pdfPathName = ConfigurationManager.AppSettings["DiskPath"] + fileObj.PDF_PATH;
                string pdfFileName = fileObj.PDF_PATH;
                pdfFileName = pdfFileName.Substring(pdfFileName.LastIndexOf('/') + 1);
                fileObj.PDF_PATH = newModelPath + "/" + pdfFileName;
                File.Copy(pdfPathName, ConfigurationManager.AppSettings["DiskPath"] + fileObj.PDF_PATH);
            }
            if (!String.IsNullOrEmpty(fileObj.SWF_PATH))
            {
                string swfPathName = ConfigurationManager.AppSettings["DiskPath"] + fileObj.SWF_PATH;
                string swfFileName = fileObj.SWF_PATH;
                swfFileName = swfFileName.Substring(swfFileName.LastIndexOf('/') + 1);
                fileObj.SWF_PATH = newModelPath + "/" + swfFileName;
                File.Copy(swfPathName, ConfigurationManager.AppSettings["DiskPath"] + fileObj.SWF_PATH);
            }
            fileBiz.Upload(fileObj);

            //newPath = Server.MapPath(newPath);
            return FileHelper.Copy(paths, newPath);
        }
        /// <summary>
        /// 课题组共享
        /// </summary>
        /// <param name="paths"></param>
        /// <param name="DesSpace">共享对象类型</param>
        /// <param name="obj_id">共享对象ID</param>
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public JsonResponse TeamShare(string paths, string name)
        {
            JsonResponse response = new JsonResponse();
            response.success = false;
            TB_TEAM_FILEBiz biz = new TB_TEAM_FILEBiz();
            string teamId = Context.Request.Cookies["team_id"].Value;
            bool config = biz.TeamShareFile(teamId, paths, name);
            if (config == true)
                response.success = true;
            return response;
        }
        /// <summary>
        /// 取消共享
        /// </summary>
        /// <param name="paths"></param>
        /// <param name="recursive"></param>
        /// <returns></returns>
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public JsonResponse CancelShareFile(string FILE_ID, string SpaceType)
        {
            JsonResponse response = new JsonResponse();
            response.success = false;
            FILE_ID = FILE_ID.Remove(FILE_ID.LastIndexOf(","), 1);
            string[] idandobjid = FILE_ID.Split(',');
            string[] ids;
            string obj_ids = "";
            string file_ids = "";
            for (int i = 0; i < idandobjid.Length; i++)
            {
                ids = idandobjid[i].Split(';');
                file_ids += ids[0] + ",";
                obj_ids += ids[1] + ",";
            }
            obj_ids = obj_ids.Remove(obj_ids.LastIndexOf(","), 1);
            file_ids = file_ids.Remove(file_ids.LastIndexOf(","), 1);
            if (SpaceType.Equals("Person"))
            {
                Tb_Person_File_ShareBiz biz = new Tb_Person_File_ShareBiz();
                biz.deleteShareFileInfoByFileId(file_ids, obj_ids);
                response.success = true;
                return response;
            }
            else
            {
                //删除课题组共享到项目库的文件
            }
            return response;
        }

        /// <summary>
        /// 课题组重新提交
        /// </summary>
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public JsonResponse TeamNewAgainDataSubmit(string FILE_ID)
        {
            JsonResponse response = new JsonResponse();
            response.success = false;
            FILE_ID = FILE_ID.Remove(FILE_ID.LastIndexOf(","), 1);

            Tb_Xmk_FileBiz bll = new Tb_Xmk_FileBiz();
            response.success = bll.NewAgainDataSubmit(FILE_ID);
            return response;

        }

        /// <summary>
        /// 重新提交
        /// </summary>
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public JsonResponse NewAgainDataSubmit(string FILE_ID)
        {
            JsonResponse response = new JsonResponse();
            response.success = false;
            FILE_ID = FILE_ID.Remove(FILE_ID.LastIndexOf(","), 1);

            TB_TEAM_FILEBiz bll = new TB_TEAM_FILEBiz();
            response.success = bll.NewAgainDataSubmit(FILE_ID);
            return response;

        }

        /// <summary>
        /// 个人放弃提交
        /// </summary>
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public JsonResponse BackFile(string FILE_ID)
        {
            JsonResponse response = new JsonResponse();
            response.success = false;

            TB_TEAM_FILEBiz bll = new TB_TEAM_FILEBiz();
            FILE_ID = FILE_ID.Remove(FILE_ID.LastIndexOf(","), 1);
            //string File_ID = this.Request.QueryString["File_ID"].ToString();
            DataTable dt = bll.GetNewModelBySql(FILE_ID);
            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    if (bll.Delete(dt.Rows[i]["FILE_ID"].ToString()))
                    {
                        //获取存放路径
                        string save_Path = ConfigurationManager.AppSettings["DiskPath"];
                        //文档名称
                        string SAVE_PATH = dt.Rows[0]["SAVE_PATH"].ToString();
                        string PDF_PATH = dt.Rows[0]["PDF_PATH"].ToString();
                        string SWF_PATH = dt.Rows[0]["SWF_PATH"].ToString();
                        //删除文件
                        //1、删除源文件
                        if (!string.IsNullOrEmpty(SAVE_PATH))
                        {
                            FileHelper.DeleteFile(save_Path + SAVE_PATH);
                        }
                        //2、删除PDF文件
                        if (!string.IsNullOrEmpty(PDF_PATH))
                        {
                            FileHelper.DeleteFile(save_Path + PDF_PATH);
                        }
                        //3、删除swf文件
                        if (!string.IsNullOrEmpty(SWF_PATH))
                        {
                            FileHelper.DeleteDirectory(save_Path + SWF_PATH, true);
                        }
                    }
                }
            }
            response.success = true;
            return response;

        }

        /// <summary>
        /// 课题组放弃提交
        /// </summary>
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public JsonResponse TeamBackFile(string FILE_ID)
        {
            JsonResponse response = new JsonResponse();
            response.success = false;
            FILE_ID = FILE_ID.Remove(FILE_ID.LastIndexOf(","), 1);
            Tb_Xmk_FileBiz bll = new Tb_Xmk_FileBiz();
            DataTable dt = bll.GetxmkModel(FILE_ID);
            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    if (bll.Delete(Convert.ToDecimal(dt.Rows[i]["FILE_ID"])))
                    {

                        //获取存放路径
                        string save_Path = ConfigurationManager.AppSettings["DiskPath"];
                        //文档名称
                        string SAVE_PATH = dt.Rows[0]["SAVE_PATH"].ToString();
                        string PDF_PATH = dt.Rows[i]["PDF_PATH"].ToString();
                        string SWF_PATH = dt.Rows[i]["SWF_PATH"].ToString();
                        //删除文件
                        //1、删除源文件
                        if (!string.IsNullOrEmpty(SAVE_PATH))
                        {
                            FileHelper.DeleteFile(save_Path + SAVE_PATH);
                        }
                        //2、删除PDF文件
                        if (!string.IsNullOrEmpty(PDF_PATH))
                        {
                            FileHelper.DeleteFile(save_Path + PDF_PATH);
                        }
                        //3、删除swf文件
                        if (!string.IsNullOrEmpty(SWF_PATH))
                        {
                            FileHelper.DeleteDirectory(save_Path + SWF_PATH, true);
                        }
                    }
                }
            }
            response.success = true;
            return response;

        }

        #endregion

        #region Zip Operation
        /// <summary>
        /// 将选中的文件，文件夹压缩到ZIP文件里
        /// </summary>
        /// <param name="paths"></param>
        /// <param name="dest"></param>
        /// <param name="zipName"></param>
        /// <param name="includeRoot"></param>
        /// <returns></returns>
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public JsonResponse Compress(string paths, string dest, string zipName)
        {
            if (Session != null && Session["sub_path"] != null)
                config.SubPath = Session["sub_path"].ToString();
            paths = paths.Replace("~/", GetBasePath());
            dest = dest.Replace("~/", config.FilesPath);

            //string saveTo = Server.MapPath(Path.Combine(dest, zipName));
            string saveTo = Path.Combine(dest, zipName);
            return ZipHelper.GenerateZipFile(paths, saveTo, "", true);
        }


        /// <summary>
        /// 下载选中文件
        /// 1.压缩选中文件
        /// 2.返回压缩好的文件下载地址
        /// </summary>
        /// <param name="paths"></param>
        /// <returns></returns>
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public JsonResponse DownloadDatas(string paths, string SpaceType)
        {
            string sourcepath = ConfigurationManager.AppSettings["DiskPath"];
            string strTmpDir = System.Web.HttpContext.Current.Request.PhysicalApplicationPath + "Temp\\";
            string strTmpDirZip = System.Web.HttpContext.Current.Request.PhysicalApplicationPath + "TempZip\\";
            string[] pathss = paths.Split(',');
            JsonResponse downloadRes = new JsonResponse();
            if (pathss.Length <= 1)
            {
                if (SpaceType.Equals("individual"))
                {
                    Directory.CreateDirectory(strTmpDir);
                    Directory.Delete(strTmpDir, true);
                    Directory.CreateDirectory(strTmpDir);
                    //如果只是一个文件的话，直接下载咯\
                    TB_PERSON_FILEBiz bll = new TB_PERSON_FILEBiz();
                    DataTable dt = bll.GetModelList(paths);
                    string sourcdownepath = "";
                    if (dt.Rows.Count > 0)
                    {
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            sourcdownepath += sourcepath + dt.Rows[i]["save_path"].ToString();
                        }
                    }
                    File.Copy(sourcdownepath, strTmpDir + dt.Rows[0]["file_name"].ToString());
                    string relativePath = Path.Combine(GetTempPath(), dt.Rows[0]["file_name"].ToString());
                    string absolutePath = VirtualPathUtility.ToAbsolute(relativePath);
                    string dest = Server.MapPath(relativePath);
                    downloadRes.message = "http://" + System.Web.HttpContext.Current.Request.Url.Host + ":" + System.Web.HttpContext.Current.Request.Url.Port + System.Web.HttpContext.Current.Request.ApplicationPath + "/Temp/" + dt.Rows[0]["file_name"].ToString();
                    downloadRes.success = true;
                }
                else if (SpaceType.Equals("group"))
                {
                    Directory.CreateDirectory(strTmpDir);
                    Directory.Delete(strTmpDir, true);
                    Directory.CreateDirectory(strTmpDir);
                    //如果只是一个文件的话，直接下载咯\
                    TB_TEAM_FILEBiz bll = new TB_TEAM_FILEBiz();
                    DataTable dt = bll.GetModelList(paths);
                    string sourcdownepath = "";
                    if (dt.Rows.Count > 0)
                    {
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            sourcdownepath += sourcepath + dt.Rows[i]["save_path"].ToString();
                        }
                    }
                    File.Copy(sourcdownepath, strTmpDir + dt.Rows[0]["file_name"].ToString());


                    downloadRes.message = "http://" + System.Web.HttpContext.Current.Request.Url.Host + ":" + System.Web.HttpContext.Current.Request.Url.Port + System.Web.HttpContext.Current.Request.ApplicationPath + "/Temp/" + dt.Rows[0]["file_name"].ToString();
                    downloadRes.success = true;
                }
                else if (SpaceType.Equals("project"))
                {
                    Directory.CreateDirectory(strTmpDir);
                    Directory.Delete(strTmpDir, true);
                    Directory.CreateDirectory(strTmpDir);
                    //如果只是一个文件的话，直接下载咯\
                    Tb_Xmk_FileBiz bll = new Tb_Xmk_FileBiz();
                    DataTable dt = bll.GetModelList(paths);
                    string sourcdownepath = "";
                    if (dt.Rows.Count > 0)
                    {
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            sourcdownepath += sourcepath + dt.Rows[i]["save_path"].ToString();
                        }
                    }
                    File.Copy(sourcdownepath, strTmpDir + dt.Rows[0]["file_name"].ToString());



                    downloadRes.message = "http://" + System.Web.HttpContext.Current.Request.Url.Host + ":" + System.Web.HttpContext.Current.Request.Url.Port + System.Web.HttpContext.Current.Request.ApplicationPath + "/Temp/" + dt.Rows[0]["file_name"].ToString();
                    downloadRes.success = true;

                }
                return downloadRes;
            }
            else
            {
                if (SpaceType.Equals("individual"))
                {
                    Directory.CreateDirectory(strTmpDir);
                    Directory.Delete(strTmpDir, true);
                    Directory.CreateDirectory(strTmpDir);
                    JsonResponse response;
                    //如果只是一个文件的话，直接下载咯\
                    TB_PERSON_FILEBiz bll = new TB_PERSON_FILEBiz();
                    DataTable dt = bll.GetModelList(paths);
                    string sourcdownepath = "";
                    string nowfilepath = "";
                    if (dt.Rows.Count > 0)
                    {
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            sourcdownepath += sourcepath + dt.Rows[i]["save_path"].ToString() + ",";

                            File.Copy(sourcepath + dt.Rows[i]["save_path"].ToString(), strTmpDir + dt.Rows[i]["file_name"].ToString());
                            nowfilepath += strTmpDir + dt.Rows[i]["file_name"].ToString() + ",";
                        }
                    }
                    string relativePath = Path.Combine(GetTempPath(), string.Format("Download_{0}.zip", DateTime.Now.ToString("yyyyMMdd_hhmmss")));
                    string absolutePath = VirtualPathUtility.ToAbsolute(relativePath);
                    string dest = Server.MapPath(relativePath);
                    response = ZipHelper.GenerateZipFile(nowfilepath, dest, "", true);
                    if (response.success)
                    {

                        downloadRes.success = true;
                        downloadRes.message = absolutePath;
                        return downloadRes;
                    }
                    else
                    {
                        return response;
                    }
                }
                else if (SpaceType.Equals("group"))
                {
                    Directory.CreateDirectory(strTmpDir);
                    Directory.Delete(strTmpDir, true);
                    Directory.CreateDirectory(strTmpDir);
                    JsonResponse response;
                    //如果只是一个文件的话，直接下载咯\
                    TB_TEAM_FILEBiz bll = new TB_TEAM_FILEBiz();
                    DataTable dt = bll.GetModelList(paths);
                    string sourcdownepath = "";
                    string nowfilepath = "";
                    if (dt.Rows.Count > 0)
                    {
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            sourcdownepath += sourcepath + dt.Rows[i]["save_path"].ToString() + ",";
                            File.Copy(sourcepath + dt.Rows[i]["save_path"].ToString(), strTmpDir + dt.Rows[i]["file_name"].ToString());
                            nowfilepath += strTmpDir + dt.Rows[i]["file_name"].ToString() + ",";
                        }
                    }
                    string relativePath = Path.Combine(GetTempPath(), string.Format("Download_{0}.zip", DateTime.Now.ToString("yyyyMMdd_hhmmss")));
                    string absolutePath = VirtualPathUtility.ToAbsolute(relativePath);
                    string dest = Server.MapPath(relativePath);
                    response = ZipHelper.GenerateZipFile(nowfilepath, dest, "", true);
                    if (response.success)
                    {

                        downloadRes.success = true;
                        downloadRes.message = absolutePath;
                        return downloadRes;
                    }
                    else
                    {
                        return response;
                    }
                }
                else if (SpaceType.Equals("project"))
                {
                    Directory.CreateDirectory(strTmpDir);
                    Directory.Delete(strTmpDir, true);
                    Directory.CreateDirectory(strTmpDir);
                    JsonResponse response;
                    //如果只是一个文件的话，直接下载咯\
                    Tb_Xmk_FileBiz bll = new Tb_Xmk_FileBiz();
                    DataTable dt = bll.GetModelList(paths);
                    string sourcdownepath = "";
                    string nowfilepath = "";
                    if (dt.Rows.Count > 0)
                    {
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            sourcdownepath += sourcepath + dt.Rows[i]["save_path"].ToString() + ",";
                            File.Copy(sourcepath + dt.Rows[i]["save_path"].ToString(), strTmpDir + dt.Rows[i]["file_name"].ToString());
                            nowfilepath += strTmpDir + dt.Rows[i]["file_name"].ToString() + ",";
                        }
                    }
                    string relativePath = Path.Combine(GetTempPath(), string.Format("Download_{0}.zip", DateTime.Now.ToString("yyyyMMdd_hhmmss")));
                    string absolutePath = VirtualPathUtility.ToAbsolute(relativePath);
                    string dest = Server.MapPath(relativePath);
                    response = ZipHelper.GenerateZipFile(nowfilepath, dest, "", true);
                    if (response.success)
                    {

                        downloadRes.success = true;
                        downloadRes.message = absolutePath;
                        return downloadRes;
                    }
                    else
                    {
                        return response;
                    }
                }
            }
            return null;
        }



        /// <summary>
        /// 将选中的文件压缩到ZIP文件里
        /// </summary>
        /// <param name="paths"></param>
        /// <param name="dest"></param>
        /// <param name="zipName"></param>
        /// <param name="includeRoot"></param>
        /// <returns></returns>
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public JsonResponse CompressDatas(string paths, string dest, string zipName)
        {
            JsonResponse js = new JsonResponse();
            string sourcepath = ConfigurationManager.AppSettings["DiskPath"];
            //if (Session != null && Session["sub_path"] != null)
            //    config.SubPath = Session["sub_path"].ToString();
            //paths = paths.Replace("~/", GetBasePath());
            //dest = dest.Replace("~/", config.FilesPath);
            TB_PERSON_FILEBiz bll = new TB_PERSON_FILEBiz();
            DataTable dt = bll.GetModelList(paths);
            string sourcdownepath = "";
            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    sourcdownepath += sourcepath + dt.Rows[i]["save_path"].ToString() + ",";
                }
            }
            sourcdownepath = sourcdownepath.Substring(0, sourcdownepath.Length - 1);
            //string saveTo = Server.MapPath(Path.Combine(dest, zipName));
            string strTmpDirZip = System.Web.HttpContext.Current.Request.PhysicalApplicationPath + "TempZip\\";
            string saveTo = Path.Combine(strTmpDirZip, zipName);
            return ZipHelper.GenerateZipFile(sourcdownepath, saveTo, "", true);


        }


        /// <summary>
        /// 解压缩ZIP文件
        /// </summary>
        /// <param name="path"></param>
        /// <param name="dest"></param>
        /// <param name="overwrite"></param>
        /// <returns></returns>
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public JsonResponse Extract(string path, string dest, bool overwrite = true)
        {
            if (Session != null && Session["sub_path"] != null)
                config.SubPath = Session["sub_path"].ToString();
            path = path.Replace("~/", config.FilesPath);
            dest = dest.Replace("~/", config.FilesPath);

            string zipPath = path;// Server.MapPath(path);
            string extractTo = dest;//Server.MapPath(dest);
            return ZipHelper.UnzipFile(zipPath, extractTo, overwrite);
        }
        #endregion

        protected byte[] ConvertStreamToByteBuffer(Stream s)
        {
            MemoryStream ms = new MemoryStream();
            int b;
            while ((b = s.ReadByte()) != -1)
            {
                ms.WriteByte((byte)b);
            }
            return ms.ToArray();
        }

        /// <summary>
        /// 下载选中文件
        /// 1.压缩选中文件
        /// 2.返回压缩好的文件下载地址
        /// </summary>
        /// <param name="paths"></param>
        /// <returns></returns>
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public byte[] DownloadFiles(string paths)
        {
            if (Session != null && Session["sub_path"] != null)
                config.SubPath = Session["sub_path"].ToString();
            if (!paths.Contains(",") && paths.Contains("."))
            {

                if (File.Exists(paths))
                {
                    try
                    {
                        FileStream s = File.OpenRead(paths);
                        return ConvertStreamToByteBuffer(s);
                    }
                    catch
                    {
                        return new byte[0];
                    }
                }
                else
                {
                    return new byte[0];
                }

            }
            else
            {
                return new byte[0];

            }
        }

        #region 属性修改
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public JsonResponse SetFileAttributes(string path, bool isReadOnly, bool isHidden, bool isSystem, bool isArchive, bool isWritable, bool isBrowsable)
        {
            if (Session != null && Session["sub_path"] != null)
                config.SubPath = Session["sub_path"].ToString();
            path = path.Replace("~/", config.FilesPath);
            if (Allowed(path, "w"))
            {
                path = Server.MapPath(path);
                return FileHelper.SetFileAttributes(path, isReadOnly, isHidden, isSystem, isArchive, isWritable, isBrowsable);
            }
            else
            {
                JsonResponse response = new JsonResponse();
                response.success = false;
                response.message = string.Format(lang_server.Get("File 0 to be protected, you cannot edit the"), path);
                return response;
            }
        }

        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public JsonResponse SetFolderAttributes(string path, bool isReadOnly, bool isHidden, bool isSystem, bool isArchive, bool isWritable, bool isBrowsable, bool recursive)
        {
            if (Session != null && Session["sub_path"] != null)
                config.SubPath = Session["sub_path"].ToString();
            path = path.Replace("~/", config.FilesPath);
            if (Allowed(path, "w"))
            {
                path = Server.MapPath(path);
                return FileHelper.SetFolderAttributes(path, isReadOnly, isHidden, isSystem, isArchive, isWritable, isBrowsable, recursive);
            }
            else
            {
                JsonResponse response = new JsonResponse();
                response.success = false;
                response.message = string.Format(lang_server.Get("The folder 0 to be protected, you cannot edit the"), path);
                return response;
            }
        }
        #endregion

        #region Create New
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public JsonResponse NewFile(string path, string name)
        {
            if (Session != null && Session["sub_path"] != null)
                config.SubPath = Session["sub_path"].ToString();
            path = path.Replace("~/", config.FilesPath);//("~/", config.BasePath);
            if (Allowed(path, "w"))
            {
                string destPath = path;//Server.MapPath(path);
                return FileHelper.CreateTextFile(destPath, name, false, "");
            }
            else
            {
                JsonResponse response = new JsonResponse();
                response.success = false;
                response.message = string.Format(lang_server.Get("The folder 0 to be protected, you cannot add a folder to the"), path);
                return response;
            }
        }

        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public JsonResponse NewFolder(string path, string name)
        {
            if (Session != null && Session["sub_path"] != null)
                config.SubPath = Session["sub_path"].ToString();
            path = path.Replace("~/", config.FilesPath);
            if (Allowed(path, "w"))
            {
                string destPath = path;//Server.MapPath(path);
                // TB_Tree_ObjectBiz objTree = new TB_Tree_ObjectBiz();
                // string mainPath = config.FilesPath;
                // objTree.AddDir(mainPath, path, name);
                return FileHelper.CreateFolder(destPath, name);
            }
            else
            {
                JsonResponse response = new JsonResponse();
                response.success = false;
                response.message = string.Format(lang_server.Get("The folder 0 to be protected, you cannot add a folder to the"), path);
                return response;
            }
        }
        #endregion
    }
    /// <summary>
    /// 课题组个人共享数据类/课题组待审核文档
    /// </summary>
    public class shareFileItem
    {
        string File_Id = "";
        string File_Name = "";
        string User_Name = "";
        string User_Id = "";
        string Create_Time;
        string Upd_Time;
        string Save_Path = "";
        string team_id = "";

        public int FileCount
        {
            get;
            set;
        }

        public string TEAM_ID
        {
            get { return team_id; }
            set { team_id = value; }

        }

        public string SAVE_PATH
        {
            get { return Save_Path; }
            set { Save_Path = value; }
        }

        public string FILE_ID
        {
            get { return File_Id; }
            set { File_Id = value; }
        }
        public string FILE_NAME
        {
            get { return File_Name; }
            set { File_Name = value; }
        }
        public string USER_ID
        {
            get { return User_Id; }
            set { User_Id = value; }
        }

        public string USER_NAME
        {
            get { return User_Name; }
            set { User_Name = value; }
        }


        public string CREATE_TIME
        {
            get { return Create_Time; }
            set { Create_Time = value; }
        }
        public string UPD_TIME
        {
            get { return Upd_Time; }
            set { Upd_Time = value; }
        }
        public string Extension { get; set; } //扩展名
        public string Type
        {
            get
            {
                Extension = Extension.Replace(".", "");
                EXTBiz biz = new EXTBiz();
                ExtTypeinfo extmode = biz.getExtCodeByExtent(Extension);
                if (extmode != null)
                {
                    return extmode.PIC_NAME;
                }
                return "130901108129_2486.png";

            }//get
        } //类型
    }
    /// <summary>
    /// 个人空间我的共享
    /// </summary>
    public class MyShareFileItem
    {
        string File_Id = "";
        string Obj_Id = "";
        string Obj_Name = "";
        string File_Name = "";
        string Create_Time;
        string Upd_Time;
        public int FileCount
        {
            get;
            set;
        }

        public string FILE_ID
        {
            get { return File_Id; }
            set { File_Id = value; }
        }
        public string SHARE_OBJ_ID
        {
            get { return Obj_Id; }
            set { Obj_Id = value; }
        }
        public string SHARE_OBJ_NAME
        {
            get { return Obj_Name; }
            set { Obj_Name = value; }
        }
        public string FILE_NAME
        {
            get { return File_Name; }
            set { File_Name = value; }
        }

        public string CREATE_TIME
        {
            get { return Create_Time; }
            set { Create_Time = value; }
        }
        public string UPD_TIME
        {
            get { return Upd_Time; }
            set { Upd_Time = value; }
        }
        public string Extension { get; set; } //扩展名
        public string Type
        {
            get
            {
                Extension = Extension.Replace(".", "");
                EXTBiz biz = new EXTBiz();
                ExtTypeinfo extmode = biz.getExtCodeByExtent(Extension);
                if (extmode != null)
                {
                    return extmode.PIC_NAME;
                }
                return "130901108129_2486.png";

            }//get
        } //类型
    }

    /// <summary>
    /// 回收站信息
    /// </summary>
    public class RecycleItem
    {
        string File_Id = "";
        string File_Name = "";
        string Space_ID = "";
        string Space_name = "";
        string File_Size = "";
        string RECYCLE_Date = "";

        public int FileCount
        {
            get;
            set;
        }
        public string FILE_ID
        {
            get { return File_Id; }
            set { File_Id = value; }
        }
        public string FILE_NAME
        {
            get { return File_Name; }
            set { File_Name = value; }
        }

        public string SPACE_ID
        {
            get { return Space_ID; }
            set { Space_ID = value; }
        }
        public string SPACE_NAME
        {
            get { return Space_name; }
            set { Space_name = value; }
        }

        public string FILE_SIZE
        {
            get { return File_Size; }
            set { File_Size = value; }
        }

        public string RECYCLE_DATE
        {
            get { return RECYCLE_Date; }
            set { RECYCLE_Date = value; }
        }
        public string Extension { get; set; } //扩展名
        public string Type
        {
            get
            {
                Extension = Extension.Replace(".", "");
                EXTBiz biz = new EXTBiz();
                ExtTypeinfo extmode = biz.getExtCodeByExtent(Extension);
                if (extmode != null)
                {
                    return extmode.PIC_NAME;
                }
                return "130901108129_2486.png";

            }//get
        } //类型
    }


    /// <summary>
    /// 个人空间我的提交
    /// </summary>
    public class MySubmitItem
    {
        string File_Id = "";
        string File_Name = "";
        string Team_Name = "";
        string Team_ID = "";
        string Statsu = "";
        string Create_Time;
        string Upd_Time;

        public int FileCount
        {
            get;
            set;
        }

        public string FILE_ID
        {
            get { return File_Id; }
            set { File_Id = value; }
        }
        public string FILE_NAME
        {
            get { return File_Name; }
            set { File_Name = value; }
        }

        public string TEAM_NAME
        {
            get { return Team_Name; }
            set { Team_Name = value; }
        }

        public string TEAM_ID
        {
            get { return Team_ID; }
            set { Team_ID = value; }
        }
        public string STATSU
        {
            get { return Statsu; }
            set { Statsu = value; }
        }

        public string CREATE_TIME
        {
            get { return Create_Time; }
            set { Create_Time = value; }
        }
        public string UPD_TIME
        {
            get { return Upd_Time; }
            set { Upd_Time = value; }
        }
        public string Extension { get; set; } //扩展名
        public string Type
        {
            get
            {
                if (Extension == null)
                {
                    return "130901108129_2486.png";
                }
                Extension = Extension.Replace(".", "");
                EXTBiz biz = new EXTBiz();
                ExtTypeinfo extmode = biz.getExtCodeByExtent(Extension);
                if (extmode != null)
                {
                    return extmode.PIC_NAME;
                }
                return "130901108129_2486.png";

            }//get
        } //类型
    }
}
